Removing legacy cruft and some basic typing#134
Merged
Merged
Conversation
Member
jamadden
commented
May 8, 2026
- A bunch of Python 2 and Pypy code
- Add some basic typing to the main public APIs and some internal APIs
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes legacy Python 2/PyPy compatibility code and deprecated API parameters, introduces basic type annotations across public/internal APIs (including publishing py.typed and adding a mypy config), and renames the datetime module to datetime_ext (with compatibility shims) to avoid stdlib name conflicts.
Changes:
- Remove Python 2-era compatibility (e.g.,
__future__imports, conditional code paths) and long-deprecated parameters (registry,pre_hook, etc.) across key APIs. - Add/adjust type annotations in core modules and Cython
.pxddeclarations; addpy.typedandtool.mypyconfiguration. - Rename
nti.externalization.datetime→nti.externalization.datetime_ext, update ZCML/docs/tests, and add backward-compat import shims.
Reviewed changes
Copilot reviewed 79 out of 80 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/nti/externalization/zcml.py | Adds typing around dynamic class creation in auto-package externalization. |
| src/nti/externalization/tests/test_zcml.py | Removes Py2 __future__ imports; import tidy. |
| src/nti/externalization/tests/test_testing.py | Removes Py2 __future__ imports. |
| src/nti/externalization/tests/test_singleton.py | Removes Py2 __future__ imports; minor import reordering. |
| src/nti/externalization/tests/test_proxy.py | Removes Py2 __future__ imports. |
| src/nti/externalization/tests/test_persistence.py | Removes Py2 __future__ imports; import ordering cleanup. |
| src/nti/externalization/tests/test_oids.py | Removes Py2 __future__ imports; minor import ordering cleanup. |
| src/nti/externalization/tests/test_internalization.py | Removes Py2 __future__ imports; import ordering cleanup. |
| src/nti/externalization/tests/test_interfaces.py | Removes Py2 __future__ imports; import ordering cleanup. |
| src/nti/externalization/tests/test_integer_strings.py | Removes Py2 __future__ imports. |
| src/nti/externalization/tests/test_factory.py | Removes Py2 __future__ imports; import ordering cleanup. |
| src/nti/externalization/tests/test_externalization.py | Import reordering; update datetime imports to datetime_ext. |
| src/nti/externalization/tests/test_dublincore.py | Removes Py2 __future__ imports; import ordering cleanup. |
| src/nti/externalization/tests/test_docs.py | Removes Py2 __future__ imports; import ordering cleanup. |
| src/nti/externalization/tests/test_datetime.py | Switches tests to datetime_ext APIs while keeping doctest suite for legacy name. |
| src/nti/externalization/tests/test_datastructures.py | Import tidy; update datetime imports to datetime_ext. |
| src/nti/externalization/tests/test_autopackage.py | Removes Py2 __future__ imports; import ordering cleanup. |
| src/nti/externalization/tests/test__compat.py | Removes Py2 __future__ imports. |
| src/nti/externalization/tests/benchmarks/profileinterfaces.py | Removes Py2 __future__ imports; import ordering cleanup. |
| src/nti/externalization/tests/benchmarks/objects.py | Removes Py2 __future__ imports; adds a basic type annotation for benchmark object. |
| src/nti/externalization/tests/benchmarks/interfaces.py | Removes Py2 __future__ imports; import ordering cleanup. |
| src/nti/externalization/tests/benchmarks/bootstrapinterfaces.py | Removes Py2 __future__ imports. |
| src/nti/externalization/tests/benchmarks/bm_user_profile.py | Removes Py2 __future__ imports; removes unused logger. |
| src/nti/externalization/tests/benchmarks/bm_singleton.py | Removes Py2 __future__ imports; import ordering cleanup. |
| src/nti/externalization/tests/benchmarks/bm_simple_registered_class.py | Removes Py2 __future__ imports; import ordering cleanup. |
| src/nti/externalization/tests/benchmarks/bm_simple_iface.py | Removes Py2 __future__ imports; import ordering cleanup. |
| src/nti/externalization/tests/benchmarks/bm_simple_iface_list.py | Removes Py2 __future__ imports; simplifies vmprofile path. |
| src/nti/externalization/tests/benchmarks/main.py | Removes Py2 __future__ imports; import ordering cleanup. |
| src/nti/externalization/tests/benchmarks/init.py | Removes Py2 __future__ imports. |
| src/nti/externalization/tests/init.py | Removes Py2 __future__ imports; import ordering cleanup. |
| src/nti/externalization/testing.py | Removes Py2 __future__ imports. |
| src/nti/externalization/singleton.py | Removes Py2 __future__ imports; defines Singleton using modern metaclass syntax; adds typing. |
| src/nti/externalization/representation.py | Removes deprecated registry param; adds casts/typing; removes Py2 YAML representer handling. |
| src/nti/externalization/py.typed | Publishes typing marker for downstream type checkers. |
| src/nti/externalization/proxy.py | Adds typing for proxy unwrapper registry; removes Py2 __future__ imports. |
| src/nti/externalization/persistence.py | Removes Py2 __future__ imports; adds a few type ignores/annotations for fallbacks. |
| src/nti/externalization/oids.py | Removes Py2 __future__ imports; adds typing for parsing/splitting OIDs and db name. |
| src/nti/externalization/numbers.py | Removes Py2 __future__ imports. |
| src/nti/externalization/internalization/updater.py | Adds overloads/typing; removes deprecated registry/pre_hook parameters. |
| src/nti/externalization/internalization/tests/test_updater.py | Removes Py2 __future__ imports; import ordering cleanup. |
| src/nti/externalization/internalization/tests/test_fields.py | Removes Py2 __future__ imports; import ordering cleanup. |
| src/nti/externalization/internalization/tests/test_externals_wo_class_mimetype.py | Removes Py2 __future__ imports; import ordering cleanup. |
| src/nti/externalization/internalization/legacy_factories.py | Removes Py2 __future__ imports; switches to stdlib logging; minor typing tweaks. |
| src/nti/externalization/internalization/fields.py | Removes Py2 string handling; adds typing and refactors exception capture. |
| src/nti/externalization/internalization/factories.py | Removes deprecated registry param; switches to stdlib logging; adds typing. |
| src/nti/externalization/internalization/externals.py | Removes Python 2 fallback import logic; simplifies imports. |
| src/nti/externalization/internalization/events.py | Adds typing for modified-attributes generation and related caches. |
| src/nti/externalization/internalization/_updater.pxd | Updates Cython declarations to match removed deprecated args and typing changes. |
| src/nti/externalization/internalization/_fields.pxd | Updates Cython declarations to match str field names and removed helpers. |
| src/nti/externalization/internalization/_factories.pxd | Updates Cython declarations for removed deprecated registry arg. |
| src/nti/externalization/internalization/_externals.pxd | Fixes Cython declaration typos for MutableSequence / component. |
| src/nti/externalization/internalization/init.py | Removes Py2 __future__ imports. |
| src/nti/externalization/interfaces.py | Adds typing for event kwargs; import ordering cleanup. |
| src/nti/externalization/integer_strings.py | Removes Py2 code paths; adds return type annotations. |
| src/nti/externalization/factory.py | Adds typing for default factory callable; removes Py2 __future__ imports. |
| src/nti/externalization/externalization/tests/test_externalizer.py | Removes Py2 __future__ imports; import ordering cleanup. |
| src/nti/externalization/externalization/standard_fields.py | Switches datetime conversion import to datetime_ext; removes Py2 __future__ imports. |
| src/nti/externalization/externalization/replacers.py | Switches to stdlib logging; removes Py2 __future__ imports. |
| src/nti/externalization/externalization/fields.py | Removes Py2 __future__ imports; removes unused logger. |
| src/nti/externalization/externalization/externalizer.py | Removes deprecated registry arg; adds typing and import cleanup. |
| src/nti/externalization/externalization/dictionary.py | Removes deprecated args; adds typing and import cleanup; returns LocatedExternalDict. |
| src/nti/externalization/externalization/_standard_fields.pxd | Updates Cython types from basestring to str. |
| src/nti/externalization/externalization/_externalizer.pxd | Updates Cython types and removes deprecated registry arg declaration. |
| src/nti/externalization/externalization/init.py | Removes deprecated helper; adds typing assertions for mutation paths and import cleanup. |
| src/nti/externalization/extension_points.py | Removes Py2 __future__ imports. |
| src/nti/externalization/dublincore.py | Removes Py2 __future__ imports; adds type ignores for fallback interfaces. |
| src/nti/externalization/datetime_ext.py | Removes Py2 checks; normalizes input type to str. |
| src/nti/externalization/datastructures.py | Adds typing on key methods; import cleanup and minor assertions. |
| src/nti/externalization/configure.zcml | Updates adapters from .datetime.* to .datetime_ext.*. |
| src/nti/externalization/autopackage.py | Adds typing for key autopackage helper methods and return values. |
| src/nti/externalization/_threadlocal.py | Adds typing/generics to thread-local manager. |
| src/nti/externalization/_interface_cache.py | Adds typing for cache instance set and function return types. |
| src/nti/externalization/_compat.py | Removes PY2/PYPY flags; adds overloads/typing for helpers. |
| src/nti/externalization/_base_interfaces.py | Adds typing on several private API helpers. |
| src/nti/externalization/init.py | Adds compatibility shim mapping nti.externalization.datetime to datetime_ext. |
| setup.py | Bumps dev version to 3.1.0.dev0. |
| pyproject.toml | Bumps minimum Cython; adds tool.mypy configuration. |
| MANIFEST.in | Includes .readthedocs.yml in source distributions. |
| docs/api/datetime.rst | Updates API docs to reference datetime_ext. |
| CHANGES.rst | Updates changelog for 3.1.0 and documents datetime rename/deprecation removals/typing. |
Comments suppressed due to low confidence (1)
src/nti/externalization/internalization/_updater.pxd:82
_argspec_cachegand_upsable_updateFromExternalObject_cachelook like misspellings of the Python globals (_argspec_cacheand_usable_updateFromExternalObject_cache) defined ininternalization/updater.py. If this pxd is meant to mirror module globals for cimport/cython optimization, the mismatched names will prevent correct access and can silently break any Cython code that expects the correctly-spelled symbols. Align these names with the actual Python globals (or remove them if they’re not intended to be exported).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.