File: check-modules-case.test

package info (click to toggle)
mypy 1.19.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,412 kB
  • sloc: python: 114,754; ansic: 13,343; cpp: 11,380; makefile: 257; sh: 28
file content (150 lines) | stat: -rw-r--r-- 3,242 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
-- Type checker test cases dealing with modules and imports on case-insensitive filesystems.

[case testCaseSensitivityDir]
# flags: --no-namespace-packages
from a import B  # E: Module "a" has no attribute "B"

[file a/__init__.py]
[file a/b/__init__.py]

[case testCaseSensitivityDirNamespacePackages]
# flags: --namespace-packages
from a import B  # E: Module "a" has no attribute "B"

[file a/__init__.py]
[file a/b/__init__.py]

[case testCaseInsensitivityDir]
# flags: --config-file tmp/mypy.ini

from a import B  # E: Module "a" has no attribute "B"
from other import x
reveal_type(x)  # N: Revealed type is "builtins.int"

[file a/__init__.py]
[file a/b/__init__.py]
[file FuNkY_CaSe/other.py]
x = 1

[file mypy.ini]
\[mypy]
mypy_path = tmp/funky_case


[case testCaseInsensitivityDirPyProjectTOML]
# flags: --config-file tmp/pyproject.toml

from a import B  # E: Module "a" has no attribute "B"
from other import x
reveal_type(x)  # N: Revealed type is "builtins.int"

[file a/__init__.py]

[file a/b/__init__.py]

[file FuNkY_CaSe/other.py]
x = 1

[file pyproject.toml]
\[tool.mypy]
mypy_path = "tmp/funky_case"


[case testPreferPackageOverFileCase]
# flags: --config-file tmp/mypy.ini
import a
[file funky/a.py]
/  # Deliberate syntax error, this file should not be parsed.
[file FuNkY/a/__init__.py]
pass

[file mypy.ini]
\[mypy]
mypy_path = tmp/funky


[case testPreferPackageOverFileCasePyProjectTOML]
# flags: --config-file tmp/pyproject.toml
import a

[file funky/a.py]
/  # Deliberate syntax error, this file should not be parsed.

[file FuNkY/a/__init__.py]
pass

[file pyproject.toml]
\[tool.mypy]
mypy_path = "tmp/funky"


[case testNotPreferPackageOverFileCase]
import a
[file a.py]
'no'()  # E: "str" not callable
[file A/__init__.py]
/  # Deliberate syntax error, this file should not be parsed.

[case testNamespacePackagePickFirstOnMypyPathCase]
# flags: --namespace-packages --config-file tmp/mypy.ini
from foo.bar import x
reveal_type(x)  # N: Revealed type is "builtins.int"
[file XX/foo/bar.py]
x = 0
[file yy/foo/bar.py]
x = ''
[file mypy.ini]
\[mypy]
mypy_path = tmp/xx, tmp/yy


[case testNamespacePackagePickFirstOnMypyPathCasePyProjectTOML]
# flags: --namespace-packages --config-file tmp/pyproject.toml
from foo.bar import x
reveal_type(x)  # N: Revealed type is "builtins.int"

[file XX/foo/bar.py]
x = 0

[file yy/foo/bar.py]
x = ''

[file pyproject.toml]
\[tool.mypy]
mypy_path = ["tmp/xx", "tmp/yy"]


[case testClassicPackageInsideNamespacePackageCase]
# flags: --namespace-packages --config-file tmp/mypy.ini
from foo.bar.baz.boo import x
reveal_type(x)  # N: Revealed type is "builtins.int"
[file xx/foo/bar/baz/boo.py]
x = ''
[file xx/foo/bar/baz/__init__.py]
[file yy/foo/bar/baz/boo.py]
x = 0
[file yy/foo/bar/__init__.py]

[file mypy.ini]
\[mypy]
mypy_path = TmP/xX, TmP/yY


[case testClassicPackageInsideNamespacePackageCasePyProjectTOML]
# flags: --namespace-packages --config-file tmp/pyproject.toml
from foo.bar.baz.boo import x
reveal_type(x)  # N: Revealed type is "builtins.int"

[file xx/foo/bar/baz/boo.py]
x = ''

[file xx/foo/bar/baz/__init__.py]

[file yy/foo/bar/baz/boo.py]
x = 0

[file yy/foo/bar/__init__.py]

[file pyproject.toml]
\[tool.mypy]
mypy_path = ["TmP/xX", "TmP/yY"]