-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
Description
Feature
Add a per-file-target-version
configuration option like Ruff
Pitch
Actually there is no way with Mypy to enforce python compatibility with older version while having specific parts of code for newer version.
Example:
- I have a project that must be still globally compatible with Python 3.9, but I include some code that would work with Python 3,12.
- My testing environment is Python 3,12.
- Because I want Python 3.9 compatibility I set
python_version
option to 3.9. - Part of the code the support python 3.12 may use
if sys.version >= (3, 12)
but because my testing environment is 3,12, this statement has no effect and Mypy treat the 3.12 code as en error while it should be checked against 3.12.