Open
Description
This example file.
import pathlib
class A:
pathlib: pathlib.Path = pathlib.Path('/')
$ mypy test.py
Success: no issues found in 1 source file
$ python3 test.py
Traceback (most recent call last):
File "/tmp/test.py", line 3, in <module>
class A:
File "/tmp/test.py", line 4, in A
pathlib: pathlib.Path = pathlib.Path('/')
^^^^^^^^^^^^
AttributeError: 'PosixPath' object has no attribute 'Path'. Did you mean: 'match'?
Expected Behavior
I would expect mypy to fail, possibly explaining why.
Actual Behavior
It succeeds, even though the type annotations cause a failure.
Your Environment
- Mypy version used: mypy 1.10.0 (compiled: yes)
- Python version used: Python 3.11.9
I had thought incorrectly that it was an issue with attrs python-attrs/attrs#1282 but @euresti provided the example to re-create the problem.
Metadata
Metadata
Assignees
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity