Skip to content

Replace deprecated typing.AnyStr with a constrained TypeVar in util.change_root - #409

Merged
jaraco merged 1 commit into
mainfrom
feature/util-anystr-typevar
Jul 5, 2026
Merged

jaraco merged 1 commit into
mainfrom
feature/util-anystr-typevar

Conversation

@jaraco

@jaraco jaraco commented Jul 5, 2026

Copy link
Copy Markdown
Member

typing.AnyStr is deprecated and slated for removal, so this replaces its use in util.change_root with an explicit TypeVar("_StrBytes", str, bytes) — preserving the same type-checking behavior (bound between str and bytes).

This originated as @sobolevn's pypa/setuptools#5232. Since setuptools/_distutils is vendored from here and overwritten on each sync, the util.py portion of that PR was routed upstream to this repo so it persists; the setuptools-owned parts (glob.py, bdist_egg.py) were merged there.

🤖 Generated with Claude Code

…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>
@Avasam

Avasam commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor

In #392 I disable static tests failing on setuptools code that distutils has no weight / effect upon. Which should resolve your failing tests here.

@jaraco
jaraco merged commit 578b9fc into main Jul 5, 2026
64 of 66 checks passed
@jaraco
jaraco deleted the feature/util-anystr-typevar branch July 5, 2026 15:36
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