8000 Expand imports in classes by A5rocks · Pull Request #11344 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Expand imports in classes #11344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add some more test cases
  • Loading branch information
A5rocks committed Oct 16, 2021
commit 98868037d06cddbe34b88d5f248e7cdbf7992bec
27 changes: 27 additions & 0 deletions test-data/unit/check-classes.test
Original file line number Diff line number Diff line change
Expand Up @@ -6910,3 +6910,30 @@ reveal_type(Foo.func) # N: Revealed type is "def () -> builtins.str"
[file a.py]
def func() -> str:
...

[case testExpandImportedMethodInNestedClass]
class Foo:
class Bar:
from a import meth

reveal_type(Foo.Bar().meth) # N: Revealed type is "def (x: builtins.int) -> builtins.int"
[file a.py]
def meth(self, x: int) -> int:
...

[case testExpandUndefinedImports]
class Foo:
from not_a_module import func

reveal_type(Foo.func) # N: Revealed type is "Any"
reveal_type(Foo().func) # N: Revealed type is "Any"

[case testExpandImportedMethodWithFollowImports]
# flags: --follow-imports=skip
class Foo:
from a import meth

reveal_type(Foo().meth) # N: Revealed type is "Any"
[file a.py]
def meth(self, x: int) -> int:
...
0