python / mypy

Optional static typing for Python
https://www.mypy-lang.org/
Other
18.56k stars 2.84k forks source link

(🐞) `dmypy` doesn't report any errors when passed an absolute file if the project is installed with a `.pth` file #18117

Open KotlinIsland opened 2 weeks ago

KotlinIsland commented 2 weeks ago

given

- test/
|-src/__init__.py
|-pyproject.toml
[project]
name = "test"
version = "1"
requires-python = ">=3.13, <3.14"
build-backend = "hatchling.build"
dependencies = [
    "mypy>=1.13.0",
]

[build-system]
requires = ["hatchling==1.25.0"]
build-backend = "hatchling.build"
> uv sync
...
> echo a > test.py
> dmypy run test.py
Daemon started
test.py:1: error: Name "a" is not defined  [name-defined]
Found 1 error in 1 file (checked 1 source file)
> echo b > test.py
> dmypy run absolute/path/to/test.py
Success: no issues found in 1 source file