-- 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"]