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
The docs for --python-version and the corresponding config option (python_version) state that they default to the Python version used to run mypy. This is not true and has never been true -- the default is fixed and taken from defaults.PYTHON3_VERSION.
My preference would be to make using PEP 561 installed stubs as simple as possible. The most straightforward way to use installed stubs would be to have both mypy and the stubs use the Python installation used to run mypy. Then no extra mypy options should be needed, if the same Python is also used to install the stub packages. This implies that --python-version should default to the Python version used to run mypy instead of the current behavior. So I'm in agreement here.
However, if we make this change, I'd like to update the errors generated when using unsupported syntax to document how to change the target Python version. For example, if the user is using Python 3.5 and tries to use the variable annotation syntax which was introduced in 3.6, the current error isn't necessarily very helpful:
foo.py:8: error: Variable annotation syntax is only supported in Python 3.6 and greater
Something like this would be better:
foo.py:8: error: Variable annotation syntax is only supported in Python 3.6 and greater
foo.py:8: note: Use Python 3.6+ to run mypy to enable 3.6 features (or use --python-version)
Great. I think improving the errors is an optional task; the situation isn't much different now (in fact it's worse now since simply running mypy with a different Python version doesn't help, and the docs are wrong about that). [CC: @ethanhs ]
Activity
JukkaL commentedon Feb 22, 2018
My preference would be to make using PEP 561 installed stubs as simple as possible. The most straightforward way to use installed stubs would be to have both mypy and the stubs use the Python installation used to run mypy. Then no extra mypy options should be needed, if the same Python is also used to install the stub packages. This implies that
--python-versionshould default to the Python version used to run mypy instead of the current behavior. So I'm in agreement here.However, if we make this change, I'd like to update the errors generated when using unsupported syntax to document how to change the target Python version. For example, if the user is using Python 3.5 and tries to use the variable annotation syntax which was introduced in 3.6, the current error isn't necessarily very helpful:
Something like this would be better:
gvanrossum commentedon Feb 23, 2018
Great. I think improving the errors is an optional task; the situation isn't much different now (in fact it's worse now since simply running mypy with a different Python version doesn't help, and the docs are wrong about that). [CC: @ethanhs ]
Set python_version to default to sys.version_info (#4686)
Set python_version to default to sys.version_info (python#4686)