Feature implementation from commits 2beb8b0..b34810b#3
Feature implementation from commits 2beb8b0..b34810b#3yashuatla wants to merge 1613 commits intofeature-base-3from
Conversation
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
Fix .files and inferred packages_distributions for .egg-info packages
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Re-sync jaraco.path 3.7.1.
…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
Defer import of zipp
This reverts commit 8436e81.
Defer import of json
Pass mypy and link issues
| """ | ||
|
|
||
| def __missing__(self, key): | ||
| return getattr(self, '_frozen', super().__missing__)(key) |
There was a problem hiding this comment.
🐛 Correctness Issue
Potential double function call in missing method.
If _frozen attribute doesn't exist and super().missing returns a callable, it will be called twice with the same key, potentially causing unexpected behavior.
Current Code (Diff):
- return getattr(self, '_frozen', super().__missing__)(key)
+ if hasattr(self, '_frozen'):
+ return self._frozen(key)
+ return super().__missing__(key)📝 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! 🚀
| return getattr(self, '_frozen', super().__missing__)(key) | |
| if hasattr(self, '_frozen'): | |
| return self._frozen(key) | |
| return super().__missing__(key) |
| class Pair(collections.namedtuple('Pair', 'name value')): | ||
| @classmethod | ||
| def parse(cls, text): | ||
| return cls(*map(str.strip, text.split("=", 1))) |
There was a problem hiding this comment.
🐛 Correctness Issue
Missing error handling for malformed input.
The parse method will raise ValueError if text doesn't contain '=' character, causing potential runtime exceptions when processing malformed input.
Current Code (Diff):
- return cls(*map(str.strip, text.split("=", 1)))
+ try:
+ return cls(*map(str.strip, text.split("=", 1)))
+ except ValueError:
+ return cls(text.strip(), "")📝 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! 🚀
| return cls(*map(str.strip, text.split("=", 1))) | |
| try: | |
| return cls(*map(str.strip, text.split("=", 1))) | |
| except ValueError: | |
| return cls(text.strip(), "") |
🔄 Dependencies Affected
importlib_metadata/init.py
Function: Unknown
Issue: Calls to Pair.parse with malformed input will cause runtime exceptions
Suggestion: Add error handling around the Pair.parse call or ensure input is properly formatted
importlib_metadata/_collections.py
Function: Unknown
Issue: Calls to Pair.parse with malformed input will cause runtime exceptions
Suggestion: Add error handling around the Pair.parse call or ensure input is properly formatted
| ) -> Optional[List[Any]]: ... # pragma: no cover | ||
|
|
||
| @overload | ||
| def get_all(self, name: str, failobj: _T) -> Union[List[Any], _T]: |
There was a problem hiding this comment.
🐛 Correctness Issue
Missing implementation in Protocol method.
The second get_all overload is missing the required '...' or 'pass' implementation, which will cause a syntax error when the file is executed.
Current Code (Diff):
- def get_all(self, name: str, failobj: _T) -> Union[List[Any], _T]:
- """
- Return all values associated with a possibly multi-valued key.
- """
+ def get_all(self, name: str, failobj: _T) -> Union[List[Any], _T]:
+ """
+ Return all values associated with a possibly multi-valued key.
+ """
+ ... # pragma: no cover📝 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! 🚀
| def get_all(self, name: str, failobj: _T) -> Union[List[Any], _T]: | |
| def get_all(self, name: str, failobj: _T) -> Union[List[Any], _T]: | |
| """ | |
| Return all values associated with a possibly multi-valued key. | |
| """ | |
| ... # pragma: no cover |
PR Summary
Add importlib_metadata package with APIs for accessing third-party package metadata
Overview
This PR introduces a new Python module
importlib_metadatathat provides APIs for accessing metadata from third-party Python packages, including classes for package discovery, metadata extraction, and entry point handling. It also includes utility modules, test fixtures, and documentation configuration.Change Types
Affected Modules
__init__.py_collections.py_functools.py_meta.py_path.py_context.pydiagnose.pyfixtures.pyexercises.pyconf.py