Feature implementation from commits 57b8aa8..5dd80c3#5
Feature implementation from commits 57b8aa8..5dd80c3#5yashuatla wants to merge 1603 commits intofeature-base-5from
Conversation
Rename empty_egg to egg_with_no_modules
Remove unnecessary list() call.
…iles for all the entries in RECORD
The import names that were created by these tests were not valid Python identifiers. Fix that, and furthermore: add another check to verify that _all_ import names returned from packages_distributions() are always valid Python identifiers. Ideally we should check that all keys returned from packages_distributions() are valid import names (i.e. can be imported), but this is at least a step in the right direction.
pep8 states that comments should be limited to 72 characters.
⚫ Fade to black.
add .get() to the PackageMetadata protocol Fixes python#384.
…ers.
The main contstraint here for an importable module is that it must not contain a module separator ('.'). Other names that contain dashes or spaces cannot be imported with the 'import' statement, but can be imported with 'importlib.import_module' or invoked with 'runpy'.
…onor that expectation.
…p-level names. Ref python#442.
Captures new failed expectation and verifies fix.
…port names" This reverts commit 70ff991. This behavior was adopted in 5e8260c and subsequently adapted as part of python#443.
…isting files for all the entries in RECORD" This reverts commit fa9cca4.
…to build the metadata RECORD from the files definition.
Use jaraco.path for generating the record and files
- wallrusify - add a note about deffered import
Speed up import time by deferring inspect
Re-sync jaraco.path 3.7.1.
…d simpler relevant comments. Ref python#142
…l' comment to delineate where the skeleton ends and the downstream begins.
…lso required for clean diffs. Ref jaraco/skeleton#142
# Conflicts: # docs/conf.py # mypy.ini
Update tests/_path.py with jaraco.path 3.7.2
| ) == '_frozen_importlib_external' and hasattr(finder, 'find_distributions') | ||
|
|
||
| for finder in filter(matches, sys.meta_path): # pragma: nocover | ||
| del finder.find_distributions |
There was a problem hiding this comment.
🐛 Correctness Issue
Critical: Monkey-patching Python's import system.
Deleting the find_distributions method from stdlib finders modifies Python's core import system in a way that could break compatibility with other packages.
Current Code (Diff):
- del finder.find_distributions
+ try:
+ del finder.find_distributions
+ except (AttributeError, TypeError):
+ pass📝 Committable suggestion
‼️ IMPORTANT
Trust, but verify! 🕵️ Please review this suggestion with the care of a code archaeologist - check that it perfectly replaces the highlighted code, preserves all lines, maintains proper indentation, and won't break anything in production. Your future self will thank you! 🚀
| del finder.find_distributions | |
| try: | |
| del finder.find_distributions | |
| except (AttributeError, TypeError): | |
| pass |
| sys.meta_path.append(cls()) | ||
| disable_stdlib_finder() | ||
| return cls |
There was a problem hiding this comment.
🐛 Correctness Issue
Critical: Unconditional stdlib finder disabling.
The install function unconditionally disables stdlib finders without any fallback mechanism, which could cause system-wide import failures.
Current Code (Diff):
- sys.meta_path.append(cls())
- disable_stdlib_finder()
- return cls
+ sys.meta_path.append(cls())
+ try:
+ disable_stdlib_finder()
+ except Exception:
+ # Log warning but continue - allows package to work even if disabling fails
+ import warnings
+ warnings.warn("Failed to disable stdlib finder, package may not work correctly")
+ return cls📝 Committable suggestion
‼️ IMPORTANT
Trust, but verify! 🕵️ Please review this suggestion with the care of a code archaeologist - check that it perfectly replaces the highlighted code, preserves all lines, maintains proper indentation, and won't break anything in production. Your future self will thank you! 🚀
| sys.meta_path.append(cls()) | |
| disable_stdlib_finder() | |
| return cls | |
| sys.meta_path.append(cls()) | |
| try: | |
| disable_stdlib_finder() | |
| except Exception: | |
| # Log warning but continue - allows package to work even if disabling fails | |
| import warnings | |
| warnings.warn("Failed to disable stdlib finder, package may not work correctly") | |
| return cls |
PR Summary
Add Importlib Metadata Package with Comprehensive Documentation and Testing
Overview
This PR introduces the importlib_metadata package with comprehensive functionality for accessing package metadata, compatibility layers for different Python versions, utility classes, and extensive test coverage.
Change Types
Affected Modules
conf.py_adapters.py_collections.py_compat.pycompat/py311.pycompat/py39.pydiagnose.pytest_api.pytest_main.pyNotes for Reviewers