Skip to content
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

Update fine-grained tests to prep for --namespace-packages support #11259

Merged
merged 1 commit into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 2 additions & 4 deletions test-data/unit/fine-grained-follow-imports.test
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,7 @@ def f(x: str) -> None: pass
[file p/m.py.3]
def f(x: str) -> None: pass

[delete p/m.py.4]
[delete p/__init__.py.4]
[delete p.4]

[out]
==
Expand All @@ -445,8 +444,7 @@ def f(x: str) -> None: pass

1()

[delete p/m.py.3]
[delete p/__init__.py.3]
[delete p.3]

[out]
==
Expand Down
52 changes: 27 additions & 25 deletions test-data/unit/fine-grained-modules.test
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,7 @@ p.f(1)
from p.a import f
[file p/a.py]
def f(x: str) -> None: pass
[delete p/__init__.py.2]
[delete p/a.py.2]
[delete p.2]
[out]
main:2: error: Argument 1 to "f" has incompatible type "int"; expected "str"
==
Expand All @@ -870,7 +869,7 @@ p.a.f(1)
[file p/a.py]
def f(x: str) -> None: pass
[delete p/a.py.2]
[delete p/__init__.py.3]
[delete p.3]
[builtins fixtures/module.pyi]
[out]
main:3: error: Argument 1 to "f" has incompatible type "int"; expected "str"
Expand All @@ -884,52 +883,55 @@ main:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missin
main:2: error: Cannot find implementation or library stub for module named "p"

[case testDeletePackage4]
# flags: --no-namespace-packages
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I filed #11322 to convert these in the future.

import p.a
p.a.f(1)
[file p/a.py]
def f(x: str) -> None: pass
[file p/__init__.py]
[delete p/__init__.py.2]
[delete p/a.py.3]
[delete p.3]
[out]
main:2: error: Argument 1 to "f" has incompatible type "int"; expected "str"
main:3: error: Argument 1 to "f" has incompatible type "int"; expected "str"
==
main:1: error: Cannot find implementation or library stub for module named "p.a"
main:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
main:1: error: Cannot find implementation or library stub for module named "p"
main:2: error: Cannot find implementation or library stub for module named "p.a"
main:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
main:2: error: Cannot find implementation or library stub for module named "p"
==
main:1: error: Cannot find implementation or library stub for module named "p.a"
main:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
main:1: error: Cannot find implementation or library stub for module named "p"
main:2: error: Cannot find implementation or library stub for module named "p.a"
main:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
main:2: error: Cannot find implementation or library stub for module named "p"

[case testDeletePackage5]
# cmd1: mypy main p/a.py p/__init__.py
# cmd2: mypy main p/a.py
# cmd3: mypy main
# flags: --no-namespace-packages
# cmd1: mypy -m main -m p.a -m p.__init__
# cmd2: mypy -m main -m p.a
# cmd3: mypy -m main

import p.a
p.a.f(1)
[file p/a.py]
def f(x: str) -> None: pass
[file p/__init__.py]
[delete p/__init__.py.2]
[delete p/a.py.3]
[delete p.3]
[out]
main:6: error: Argument 1 to "f" has incompatible type "int"; expected "str"
main:7: error: Argument 1 to "f" has incompatible type "int"; expected "str"
==
main:5: error: Cannot find implementation or library stub for module named "p.a"
main:5: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
main:5: error: Cannot find implementation or library stub for module named "p"
main:6: error: Cannot find implementation or library stub for module named "p.a"
main:6: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
main:6: error: Cannot find implementation or library stub for module named "p"
==
main:5: error: Cannot find implementation or library stub for module named "p.a"
main:5: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
main:5: error: Cannot find implementation or library stub for module named "p"
main:6: error: Cannot find implementation or library stub for module named "p.a"
main:6: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
main:6: error: Cannot find implementation or library stub for module named "p"


[case testDeletePackage6]
# cmd1: mypy p/a.py p/b.py p/__init__.py
# cmd2: mypy p/a.py p/b.py
# cmd3: mypy p/a.py p/b.py
# flags: --no-namespace-packages
# cmd1: mypy -m p.a -m p.b -m p.__init__
# cmd2: mypy -m p.a -m p.b
# cmd3: mypy -m p.a -m p.b
[file p/a.py]
def f(x: str) -> None: pass
[file p/b.py]
Expand Down