You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use # type: ignore to ignore certain false positives (errors) produced by mypy. In our project, I use multiple python versions, and, in particular, 3.8.13 and 3.9.13. I've noticed that mypy produces a different output for these 2 different versions of Python.
To Reproduce
Create the file main.py with the following contents
Run mypy main.py with Python 3.8.13 and 3.9.13 and see that, in 3.9.13, the #type: ignore is not applicable to the whole fstring, but just the first line, while in 3.8.13 it seems to be applicable to the whole string. Of course, if I don't split the fstring into multiple lines, this doesn't happen.
In order to make mypy not report any error in 3.9.13, I need to do the following
However, this does not work in Python 3.8.13. I would need also to place # type: ignore in front of the first line (like in the example above). So, in order to make this run in both versions, I need 3 comments, apparently
Expected Behavior
Mypy behaves in the same way in different python versions, if I am using the same dependencies
Actual Behavior
the opposite
Your Environment
Mypy version used: 0.950
Mypy command-line flags: None
Mypy configuration options from mypy.ini (and other config files):
...
# Configs in the pyproject.toml
[tool.mypy]
python_version = 3.8
warn_return_any = true
warn_unused_configs = true
...
The behaviour above doesn't change if I use python_version = 3.9
Python version used: 3.8.13 and 3.9.13
The text was updated successfully, but these errors were encountered:
I'm guessing that this is due to changes in the AST between Python 3.8 and 3.9.
In any case, I'm not able to repro the original problem even with older versions of mypy and Python 3.8 or Python 3.9. I'm not sure why a # type: ignore would be necessary here.
Bug Report
I'm trying to use
# type: ignore
to ignore certain false positives (errors) produced by mypy. In our project, I use multiple python versions, and, in particular, 3.8.13 and 3.9.13. I've noticed that mypy produces a different output for these 2 different versions of Python.To Reproduce
Create the file
main.py
with the following contentsRun
mypy main.py
with Python 3.8.13 and 3.9.13 and see that, in 3.9.13, the#type: ignore
is not applicable to the whole fstring, but just the first line, while in 3.8.13 it seems to be applicable to the whole string. Of course, if I don't split the fstring into multiple lines, this doesn't happen.In order to make mypy not report any error in 3.9.13, I need to do the following
However, this does not work in Python 3.8.13. I would need also to place
# type: ignore
in front of the first line (like in the example above). So, in order to make this run in both versions, I need 3 comments, apparentlyExpected Behavior
Mypy behaves in the same way in different python versions, if I am using the same dependencies
Actual Behavior
the opposite
Your Environment
mypy.ini
(and other config files):The behaviour above doesn't change if I use
python_version = 3.9
The text was updated successfully, but these errors were encountered: