Skip to content

Conversation

@RonnyPfannschmidt
Copy link
Member

Refactor legacy setuptools compatibility code into a dedicated _compat module and add comprehensive tests for the list_plugin_distributions() API.

Depends on #616 - to be merged after.

RonnyPfannschmidt and others added 4 commits October 27, 2025 10:15
- Add dependency-groups for dev and testing in pyproject.toml
- Configure uv to use both groups by default
- Add uv.lock for reproducible environments
- Update .gitignore for uv cache

This enables faster, more reliable dependency management using uv.
Tools like mypy and ruff are managed via pre-commit hooks.
Add development documentation for Claude Code (claude.ai/code) including:
- Project overview
- Development commands using uv
- Development process guidelines
- Core architecture overview

Also add Claude settings to allow running approved commands directly.

Co-Authored-By: Claude <noreply@anthropic.com>
- Bump requires-python to >=3.10 in pyproject.toml
- Remove Python 3.9 from classifiers, CI matrix, tox envlist
- Update PyPy version references (pypy3.9 → pypy3.10)
- Modernize type hints: Union → |, Optional → | None
- Move Callable imports to collections.abc
- Update pyupgrade to --py310-plus

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Replace .format() with f-string in _tracing.py
- Use walrus operator for dict.get() pattern in _tracing.py
- Convert string concatenation to parenthesized f-strings in _callers.py

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@RonnyPfannschmidt RonnyPfannschmidt force-pushed the refactor/setuptools-compat-module branch from 265ca7f to 242146c Compare October 27, 2025 09:19
Copy link
Member

@bluetech bluetech left a comment

Choose a reason for hiding this comment

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

LGTM. Would make more sense to squash the two commits, no reason to add the test in a separate commit.

BTW I find the commit messages which list all changes to be useless, I'd remove them or rewrite them in human-speak.

Comment on lines +424 to +428
Returns modern :class:`importlib.metadata.Distribution` objects without
the legacy pkg_resources compatibility layer.
Copy link
Member

Choose a reason for hiding this comment

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

I think it's better in the new method just not to mention the legacy stuff or talk about "modern".

assert ret_modern[0][1] == dist # type: ignore[comparison-overlap]

# Verify the old API wraps with DistFacade while new API doesn't
from pluggy._compat import DistFacade
Copy link
Member

Choose a reason for hiding this comment

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

No reason to import lazily.

RonnyPfannschmidt and others added 3 commits October 27, 2025 10:44
Leverage TypeAlias (available in Python 3.10+) to explicitly mark
type aliases throughout the codebase:

- _hooks.py: _Namespace, _Plugin, _HookExec, _HookImplFunction, _CallHistory
- _manager.py: _BeforeTrace, _AfterTrace
- _result.py: _ExcInfo
- _callers.py: Teardown

This improves IDE support, type checker accuracy, and makes the
distinction between type aliases and regular assignments clear.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Create src/pluggy/_compat.py for legacy pkg_resources compatibility
- Move DistFacade from _manager.py to _compat.py
- Update PluginManager to use stdlib Distribution internally
- Add new list_plugin_distributions() method returning unwrapped Distribution objects
- Update list_plugin_distinfo() to wrap with DistFacade for backward compatibility
- Update test import to use _compat module

This separates legacy setuptools API emulation from modern importlib.metadata usage,
while maintaining full backward compatibility.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add test coverage for the new list_plugin_distributions() method
- Verify it returns unwrapped importlib.metadata.Distribution objects
- Confirm DistFacade wrapping only in legacy list_plugin_distinfo()
- Extend existing test_load_setuptools_instantiation test

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@RonnyPfannschmidt RonnyPfannschmidt force-pushed the refactor/setuptools-compat-module branch from 242146c to 28fcb7d Compare October 27, 2025 09:46
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.

2 participants