Skip to content

Fix symlinked partial stub packages - #11516

Merged
Rich Chiodo (rchiodo) merged 1 commit into
microsoft:mainfrom
tamird:tamird/fix-partial-stub-symlinks
Jun 22, 2026
Merged

Rich Chiodo (rchiodo) merged 1 commit into
microsoft:mainfrom
tamird:tamird/fix-partial-stub-symlinks

Conversation

@tamird

Copy link
Copy Markdown
Contributor

Partial stub packages are overlaid onto their runtime packages. When a
file in the stub package is a symbolic link, its directory entry reports
that it is a link rather than a file. ReadOnlyAugmentedFileSystem
currently converts that entry to a virtual directory, so import
resolution ignores the .pyi and falls back to the runtime .py.

Resolve symbolic links before constructing virtual directory entries.
Dangling links and special files are omitted rather than exposed as
directories. This preserves the partial stub overlay for environments
that install wheel files as symbolic links.

@tamird
Tamir Duberstein (tamird) force-pushed the tamird/fix-partial-stub-symlinks branch from bb657e1 to 57a8882 Compare June 21, 2026 14:08
@rchiodo

Copy link
Copy Markdown
Collaborator

The fix itself looks correct and is well-targeted. Main ask: align the two new tests with the repo's documented exact-assertion pattern used by their peers (count-based asserts + a non-optional entry guard). There's also one optional robustness note on the readdir change for filesystems that report unknown dirent types.

Classify this as a Pyright filesystem bug (B). A mapped entry can be
a symlink even when its target is a file. Treating Dirent.isFile()
as the virtual entry type therefore turns symlinked partial .pyi files
into directories, and import resolution falls back to runtime source.

Resolve mapped entries whose directory entry is not already known to be a
file or directory. This covers symlinks and DT_UNKNOWN entries. Ignore
dangling links and special-file targets rather than exposing them as
directories. This preserves the partial stub overlay and its type
precision.
@tamird
Tamir Duberstein (tamird) force-pushed the tamird/fix-partial-stub-symlinks branch from 57a8882 to fb65044 Compare June 22, 2026 12:56

@rchiodo Rich Chiodo (rchiodo) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved via Review Center.

@tamird

Copy link
Copy Markdown
Contributor Author

Thanks for the review! It would be great to see this in a release soon.

@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. ✅

@rchiodo

Copy link
Copy Markdown
Collaborator

Thanks for the PR

@rchiodo
Rich Chiodo (rchiodo) merged commit 11f5588 into microsoft:main Jun 22, 2026
15 of 16 checks passed
@tamird
Tamir Duberstein (tamird) deleted the tamird/fix-partial-stub-symlinks branch June 22, 2026 17:04
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