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
{{ message }}
Repository navigation
sys.version_info is assumed to be (3, 5), even on Python 3.6 #2836
Running Python 3.6, I noticed that any type hints that I add to the stub files with a if sys.version_info >= (3, 6): condition, don't have any effect.
After investigating this a little, it seems that semanal.py uses the PYTHON3_VERSION value inside default.py module as sys.version_info and it is currently hardcoded as 3.5.
Using mypy.ini config file with the following content fixes the issue:
[mypy]
python_version = 3.6
But still the default behaviour is confusing and probably should be changed.
changed the title [-]Python sys.version_info is assumed to be 3.5, even on 3.6 python[/-][+]Python sys.version_info is assumed to be 3.5, even on 3.6[/+]on Feb 9, 2017
changed the title [-]Python sys.version_info is assumed to be 3.5, even on 3.6[/-][+]sys.version_info is assumed to be (3, 5), even on Python 3.6[/+]on Feb 9, 2017
I'd prefer to make the default Python version to always be the latest supported official Python release available at the time of mypy release -- currently that would be 3.6. Here's my reasoning:
It would be consistent with how mypy behaved until recently (hard coding 3.5 as the default).
New users may mistakenly think that mypy doesn't support 3.6 features at all if they happen to first try running mypy using Python 3.5, since they may not be aware of --python-version. This could be fixed by making the error messages more informative, though.
Users may run mypy and the program they are developing using different versions of Python, perhaps not even realizing this. If this happens, it may be unclear why mypy doesn't support 3.6 features.
If the default is dynamic, it may result in confusion, as it looks like mypy works differently in different environments with different Python versions installed.
If there are multiple developers, different developers might use a different Python version to run mypy. Again, this may be a little confusing if the users haven't yet figured out how to configure the Python version explicitly.
Mypy generally is permissive by default. Here it seems consistent to allow all Python features by default.
While there are other concerns (for smaller installations there's likely
only one relevant Python 3 version) I am convinced by Jukka and I think we
should just bump the default version to 3.6.
Activity
[-]Python sys.version_info is assumed to be 3.5, even on 3.6 python[/-][+]Python sys.version_info is assumed to be 3.5, even on 3.6[/+][-]Python sys.version_info is assumed to be 3.5, even on 3.6[/-][+]sys.version_info is assumed to be (3, 5), even on Python 3.6[/+]gvanrossum commentedon Feb 9, 2017
Hm, I suppose we should make the default dynamic. I can't think of a good reason why the default should be hard-coded.
(Didn't you mean 3.6 in your example though?)
5j9 commentedon Feb 9, 2017
Yes, sorry, 3.6 is correct. Fixed.
JukkaL commentedon Feb 9, 2017
I'd prefer to make the default Python version to always be the latest supported official Python release available at the time of mypy release -- currently that would be 3.6. Here's my reasoning:
--python-version. This could be fixed by making the error messages more informative, though.gvanrossum commentedon Feb 10, 2017
gvanrossum commentedon Feb 14, 2017
Use
mypy --python-version 3.6.gvanrossum commentedon Feb 14, 2017
Oh, I think that's due to the typed-ast update. Try this remedy: #2862
gvanrossum commentedon Feb 14, 2017
Default to type checking in Python 3.6 mode
Default to type checking in Python 3.6 mode (#2915)