Skip to content

Docs for --python-version are wrong #4620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gvanrossum opened this issue Feb 22, 2018 · 2 comments
Closed

Docs for --python-version are wrong #4620

gvanrossum opened this issue Feb 22, 2018 · 2 comments

Comments

@gvanrossum
Copy link
Member

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.

In the discussion about the PEP 561 implementation I've talked myself into believing that we should do what the docs state rather than what we currently implement.

@JukkaL Before we go ahead with this change I'd like your opinion, please.

@JukkaL
Copy link
Collaborator

JukkaL commented 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-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)

@gvanrossum
Copy link
Member Author

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 ]

gvanrossum pushed a commit that referenced this issue Mar 6, 2018
This sets the default Python version used for type checking to `sys.version_info`.

Fixes #4620.

The design of this is such that we set tests to default to the running Python whenever possible, but modify tests that use new syntax and libraries to run on Python 3.5 or 3.6.

Example output of failing tests on 3.4 before test changes https://gist.github.com/ethanhs/f782bec70eab0678d9e869465b40a571#file-output-log-L512.

This was split out of #4403.
yedpodtrzitko pushed a commit to kiwicom/mypy that referenced this issue Mar 15, 2018
This sets the default Python version used for type checking to `sys.version_info`.

Fixes python#4620.

The design of this is such that we set tests to default to the running Python whenever possible, but modify tests that use new syntax and libraries to run on Python 3.5 or 3.6.

Example output of failing tests on 3.4 before test changes https://gist.github.com/ethanhs/f782bec70eab0678d9e869465b40a571#file-output-log-L512.

This was split out of python#4403.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants