Repository navigation
Remove typing.AnyStr usage - #5232
Conversation
|
Thanks @sobolevn ! Note that any change to the Since this won't be immediately marked as deprecated, I'm tempted to recommend to this project's maintainers to use https://docs.astral.sh/ruff/rules/banned-api/ / https://docs.astral.sh/ruff/settings/#lint_flake8-tidy-imports_banned-api to prevent accidentally adding it back. |
|
Tick the box to add this pull request to the merge queue (same as
|
…utils. setuptools/_distutils is vendored from pypa/distutils and is overwritten on each sync, so the AnyStr change to util.py would be lost (and could conflict on the next sync). Keeping the setuptools-owned changes (bdist_egg.py, glob.py). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Thanks @sobolevn! I pushed a small commit reverting the |
|
Follow-up: I sent the |
|
@jaraco thank you! Sorry for the late response, it got lost in my notifications :( |
The AnyStr replacement in #5232 used a bound TypeVar (bound=str | bytes), but AnyStr is a constrained TypeVar. The stdlib os.path/os.walk/GenericPath signatures are themselves constrained, so a bound TypeVar (which admits the str | bytes union) is rejected as an argument. Restore AnyStr's original semantics with TypeVar(..., str, bytes). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…hange_root typing.AnyStr is deprecated (PEP 695 era) and slated for removal. Use an explicit TypeVar constrained to (str, bytes) to preserve the same typing behavior for change_root. Originally proposed by @sobolevn in pypa/setuptools#5232, where distutils is vendored; making the change here so it persists through the next sync. Co-Authored-By: sobolevn <46602750+sobolevn@users.noreply.github.com> Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Summary of changes
Hi 👋
We are deprecating
AnyStrwith a warning since Python 3.16, this is a proactive PR to replace it with a modern alternative.Context python/cpython#150190
Pull Request Checklist
newsfragments/.(See documentation for details)
This is not really a user-facing change (at least it should not be), so no changelog entries.