Skip to content

Fix symlinked standard-library path detection - #21838

Draft
aryansk wants to merge 1 commit into
python:masterfrom
aryansk:codex/mypy-21474
Draft

Fix symlinked standard-library path detection#21838
aryansk wants to merge 1 commit into
python:masterfrom
aryansk:codex/mypy-21474

Conversation

@aryansk

@aryansk aryansk commented Aug 12, 2026

Copy link
Copy Markdown

Fixes #21474.

sysconfig.get_path("stdlib") can return a symlinked path while Python exposes the resolved target in sys.path, as with Homebrew installations. getsyspath() now compares real paths when excluding the host standard library, while preserving the absolute path spelling returned for non-standard-library entries. Added a regression test covering the symlinked layout.

Testing:

  • uv run --no-project --python 3.13 --with pytest --with mypy-extensions --with typing_extensions --with pathspec --with librt --with ast-serialize python -m pytest -q -o addopts="" mypy/test/testpyinfo.py
  • uv run --no-project --python 3.13 --with pre-commit pre-commit run --files mypy/pyinfo.py mypy/test/testpyinfo.py

Prepared with AI assistance; maintainer review is requested.

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

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.

pyinfo.getsyspath() doesn't exclude stdlib from package_path when install path contains symlinks

1 participant