| 1 |
-- Type checker test cases dealing with modules and imports on case-insensitive filesystems. |
| 2 |
|
| 3 |
[case testCaseSensitivityDir] |
| 4 |
# flags: --no-namespace-packages |
| 5 |
from a import B # E: Module "a" has no attribute "B" |
| 6 |
|
| 7 |
[file a/__init__.py] |
| 8 |
[file a/b/__init__.py] |
| 9 |
|
| 10 |
[case testCaseSensitivityDirNamespacePackages] |
| 11 |
# flags: --namespace-packages |
| 12 |
from a import B # E: Module "a" has no attribute "B" |
| 13 |
|
| 14 |
[file a/__init__.py] |
| 15 |
[file a/b/__init__.py] |
| 16 |
|
| 17 |
[case testCaseInsensitivityDir] |
| 18 |
# flags: --config-file tmp/mypy.ini |
| 19 |
|
| 20 |
from a import B # E: Module "a" has no attribute "B" |
| 21 |
from other import x |
| 22 |
reveal_type(x) # N: Revealed type is "builtins.int" |
| 23 |
|
| 24 |
[file a/__init__.py] |
| 25 |
[file a/b/__init__.py] |
| 26 |
[file FuNkY_CaSe/other.py] |
| 27 |
x = 1 |
| 28 |
|
| 29 |
[file mypy.ini] |
| 30 |
\[mypy] |
| 31 |
mypy_path = tmp/funky_case |
| 32 |
|
| 33 |
|
| 34 |
[case testCaseInsensitivityDirPyProjectTOML] |
| 35 |
# flags: --config-file tmp/pyproject.toml |
| 36 |
|
| 37 |
from a import B # E: Module "a" has no attribute "B" |
| 38 |
from other import x |
| 39 |
reveal_type(x) # N: Revealed type is "builtins.int" |
| 40 |
|
| 41 |
[file a/__init__.py] |
| 42 |
|
| 43 |
[file a/b/__init__.py] |
| 44 |
|
| 45 |
[file FuNkY_CaSe/other.py] |
| 46 |
x = 1 |
| 47 |
|
| 48 |
[file pyproject.toml] |
| 49 |
\[tool.mypy] |
| 50 |
mypy_path = "tmp/funky_case" |
| 51 |
|
| 52 |
|
| 53 |
[case testPreferPackageOverFileCase] |
| 54 |
# flags: --config-file tmp/mypy.ini |
| 55 |
import a |
| 56 |
[file funky/a.py] |
| 57 |
/ # Deliberate syntax error, this file should not be parsed. |
| 58 |
[file FuNkY/a/__init__.py] |
| 59 |
pass |
| 60 |
|
| 61 |
[file mypy.ini] |
| 62 |
\[mypy] |
| 63 |
mypy_path = tmp/funky |
| 64 |
|
| 65 |
|
| 66 |
[case testPreferPackageOverFileCasePyProjectTOML] |
| 67 |
# flags: --config-file tmp/pyproject.toml |
| 68 |
import a |
| 69 |
|
| 70 |
[file funky/a.py] |
| 71 |
/ # Deliberate syntax error, this file should not be parsed. |
| 72 |
|
| 73 |
[file FuNkY/a/__init__.py] |
| 74 |
pass |
| 75 |
|
| 76 |
[file pyproject.toml] |
| 77 |
\[tool.mypy] |
| 78 |
mypy_path = "tmp/funky" |
| 79 |
|
| 80 |
|
| 81 |
[case testNotPreferPackageOverFileCase] |
| 82 |
import a |
| 83 |
[file a.py] |
| 84 |
'no'() # E: "str" not callable |
| 85 |
[file A/__init__.py] |
| 86 |
/ # Deliberate syntax error, this file should not be parsed. |
| 87 |
|
| 88 |
[case testNamespacePackagePickFirstOnMypyPathCase] |
| 89 |
# flags: --namespace-packages --config-file tmp/mypy.ini |
| 90 |
from foo.bar import x |
| 91 |
reveal_type(x) # N: Revealed type is "builtins.int" |
| 92 |
[file XX/foo/bar.py] |
| 93 |
x = 0 |
| 94 |
[file yy/foo/bar.py] |
| 95 |
x = '' |
| 96 |
[file mypy.ini] |
| 97 |
\[mypy] |
| 98 |
mypy_path = tmp/xx, tmp/yy |
| 99 |
|
| 100 |
|
| 101 |
[case testNamespacePackagePickFirstOnMypyPathCasePyProjectTOML] |
| 102 |
# flags: --namespace-packages --config-file tmp/pyproject.toml |
| 103 |
from foo.bar import x |
| 104 |
reveal_type(x) # N: Revealed type is "builtins.int" |
| 105 |
|
| 106 |
[file XX/foo/bar.py] |
| 107 |
x = 0 |
| 108 |
|
| 109 |
[file yy/foo/bar.py] |
| 110 |
x = '' |
| 111 |
|
| 112 |
[file pyproject.toml] |
| 113 |
\[tool.mypy] |
| 114 |
mypy_path = ["tmp/xx", "tmp/yy"] |
| 115 |
|
| 116 |
|
| 117 |
[case testClassicPackageInsideNamespacePackageCase] |
| 118 |
# flags: --namespace-packages --config-file tmp/mypy.ini |
| 119 |
from foo.bar.baz.boo import x |
| 120 |
reveal_type(x) # N: Revealed type is "builtins.int" |
| 121 |
[file xx/foo/bar/baz/boo.py] |
| 122 |
x = '' |
| 123 |
[file xx/foo/bar/baz/__init__.py] |
| 124 |
[file yy/foo/bar/baz/boo.py] |
| 125 |
x = 0 |
| 126 |
[file yy/foo/bar/__init__.py] |
| 127 |
|
| 128 |
[file mypy.ini] |
| 129 |
\[mypy] |
| 130 |
mypy_path = TmP/xX, TmP/yY |
| 131 |
|
| 132 |
|
| 133 |
[case testClassicPackageInsideNamespacePackageCasePyProjectTOML] |
| 134 |
# flags: --namespace-packages --config-file tmp/pyproject.toml |
| 135 |
from foo.bar.baz.boo import x |
| 136 |
reveal_type(x) # N: Revealed type is "builtins.int" |
| 137 |
|
| 138 |
[file xx/foo/bar/baz/boo.py] |
| 139 |
x = '' |
| 140 |
|
| 141 |
[file xx/foo/bar/baz/__init__.py] |
| 142 |
|
| 143 |
[file yy/foo/bar/baz/boo.py] |
| 144 |
x = 0 |
| 145 |
|
| 146 |
[file yy/foo/bar/__init__.py] |
| 147 |
|
| 148 |
[file pyproject.toml] |
| 149 |
\[tool.mypy] |
| 150 |
mypy_path = ["TmP/xX", "TmP/yY"] |