Skip to content

Comments

Feature implementation from commits 2beb8b0..b34810b#3

Open
yashuatla wants to merge 1613 commits intofeature-base-3from
feature-head-3
Open

Feature implementation from commits 2beb8b0..b34810b#3
yashuatla wants to merge 1613 commits intofeature-base-3from
feature-head-3

Conversation

@yashuatla
Copy link
Owner

@yashuatla yashuatla commented Jun 22, 2025

PR Summary

Add importlib_metadata package with APIs for accessing third-party package metadata

Overview

This PR introduces a new Python module importlib_metadata that 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

Type Description
Feature New importlib_metadata module with APIs for package metadata access
Feature Utility modules for collections, functions, and path handling
Feature Diagnostic tools for inspecting package distributions
Enhancement Sphinx documentation configuration with improved linking
Test Performance testing functions and test fixtures

Affected Modules

Module / File Change Description
__init__.py Core importlib_metadata module with APIs for package metadata access
_collections.py FreezableDefaultDict and Pair classes for collections handling
_functools.py Utility functions from jaraco.functools including method_cache
_meta.py Protocol classes for package metadata and path handling
_path.py Filesystem utilities for symlinks and file structure building
_context.py 'suppress' class for exception suppression with decorator support
diagnose.py Diagnostic functions for inspecting package distributions
fixtures.py Test fixtures and utilities for testing environments
exercises.py Performance testing functions for importlib_metadata functionality
conf.py Sphinx documentation configuration with Python issue linking

jaraco and others added 30 commits March 25, 2023 11:24
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'.
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>
jaraco and others added 27 commits August 21, 2024 07:19
Re-sync jaraco.path 3.7.1.
# Conflicts:
#	docs/conf.py
#	mypy.ini
Update tests/_path.py with jaraco.path 3.7.2
"""

def __missing__(self, key):
return getattr(self, '_frozen', super().__missing__)(key)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐛 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! 🚀

Suggested change
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)))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐛 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! 🚀

Suggested change
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]:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐛 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! 🚀

Suggested change
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.