Skip to content

Conversation

Gankra
Copy link
Contributor

@Gankra Gankra commented Aug 19, 2025

In implementing partial stubs I had observed that this continue in the namespace package code seemed erroneous since the same continue for partial stubs didn't work. Unfortunately I wasn't confident enough to push on that hunch. Fortunately I remembered that hunch to make this an easy fix.

The issue with the continue is that it bails out of the current search-path without testing any .py files. This breaks when for example google and google-stubs/types-google are both in the same site-packages dir -- failing to find a module in types-google has us completely skip over google!

Fixes astral-sh/ty#520

@Gankra Gankra requested a review from carljm as a code owner August 19, 2025 19:50
@Gankra Gankra added the bug Something isn't working label Aug 19, 2025
@Gankra Gankra added the ty Multi-file analysis & type inference label Aug 19, 2025
Copy link
Contributor

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

Copy link
Contributor

mypy_primer results

No ecosystem changes detected ✅
No memory usage changes detected ✅

Comment on lines -57 to +59
`/packages/foo-stubs/both.py`:
`/packages/foo-stubs/both.pyi`:

```py
```pyi
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(All these changes are a driveby fix that doesn't change the results but I realized was wrong and should be fixed)


## Namespace stub with missing module

Namespace stubs are always partial.
Copy link
Member

Choose a reason for hiding this comment

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

Do you have a reference that backs this claim? This is somewhat surprising to me and I remember that I struggled to find good documentation for what's supposed to happen in some of those non obvious cases

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://peps.python.org/pep-0561/#partial-stub-packages

Type checkers should treat namespace packages within stub-packages as incomplete since multiple distributions may populate them. Regular packages within namespace packages in stub-package distributions are considered complete unless a py.typed with partial\n is included.

Copy link
Member

Choose a reason for hiding this comment

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

It would be great to add this link to the test

Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

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

Looks good, thank you!

@Gankra Gankra merged commit c82e255 into main Aug 19, 2025
40 checks passed
@Gankra Gankra deleted the gankra/fix-cont branch August 19, 2025 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ty Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unresolved-import for google.cloud packages when types-protobuf is installed
3 participants