-
Notifications
You must be signed in to change notification settings - Fork 125
Open
Labels
bugSomething isn't workingSomething isn't workingstubsissues with understanding stub (pyi) filesissues with understanding stub (pyi) filestyping semanticstyping-module features, spec compliance, etctyping-module features, spec compliance, etc
Description
Summary
We've been seeing strange diagnostics like this in ecosystem reports for bokeh, and they're starting to show up more as we add more functionality to ty:
src/bokeh/model/model.py:496:16: error[invalid-return-type] Return type does not match returned value: expected `set[src.bokeh.model.model.Model]`, found `set[src.bokeh.model.model.Model]`
A minimal repro of this issue looks something like the following:
`package/__init__.py`:
```py
from .foo import MyClass
def make_MyClass() -> MyClass:
return MyClass()
```
`package/foo.pyi`:
```py
class MyClass: ...
```
`package/foo.py`:
```py
class MyClass: ...
def get_MyClass() -> MyClass:
from . import make_MyClass
# error: [invalid-return-type] "Return type does not match returned value: expected `package.foo.MyClass`, found `package.foo.MyClass`"
return make_MyClass()
```
The issue is that ty:
- Views
MyClass
from thefoo.py
file andMyClass
fromfoo.pyi
as being different classes - Understands the
get_MyClass
function as being annotated as returning an instance ofMyClass
fromfoo.py
- Understands the
get_MyClass
function as actually returning an instance ofMyClass
fromfoo.pyi
I propose that we fix this by adding handling to make two nominal-instance types equivalent to each other if the two types come from modules that have the same fully qualified module names and come from the same search path.
Version
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingstubsissues with understanding stub (pyi) filesissues with understanding stub (pyi) filestyping semanticstyping-module features, spec compliance, etctyping-module features, spec compliance, etc