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
Potentially merge Python 2 and 3 stubs for many modules #4
We'd need to add aliases for string-like types such as str/bytes/unicode, and these would be different between Python 2 and 3. We'd need to decide where to define the type aliases, either in the stub of the module that uses them or in a shared typeshed-related (?) module that is only available as a stub.
Sharing code between pyi files sounds even more useful for https://github.com/JukkaL/typeshed/issues/3
Imagine a package with a lot of files (like e.g. numpy), and only two or three change between versions.
In terms of storing a duplicate modules in the github repo, we could just use symlinks.
However, concerning type aliases, I'm not sure how often we'll see the case that the Python 2 and the Python 3 version off the stub are exactly the same, except one uses unicode and the other uses str.
In 2020, it seems like it could be unnecessary burden (and potentially cause errors in py2 stubs by py3-minded people) to merge py2 and py3 stubs using version checks. It's a different matter if the files are identical, but a quick command makes it seem like that's not really the case, see details.
Details
Files which have the same content hash, compare to what's enforced by check_consistent.py
Activity
vlasovskikh commentedon Apr 13, 2015
Here is what we found useful in PyCharm (written using our old syntax):
matthiaskramm commentedon Apr 17, 2015
Sharing code between pyi files sounds even more useful for https://github.com/JukkaL/typeshed/issues/3
Imagine a package with a lot of files (like e.g. numpy), and only two or three change between versions.
In terms of storing a duplicate modules in the github repo, we could just use symlinks.
However, concerning type aliases, I'm not sure how often we'll see the case that the Python 2 and the Python 3 version off the stub are exactly the same, except one uses unicode and the other uses str.
gvanrossum commentedon Jan 26, 2016
Once mypy (and other systems) support version checks as described in PEP 484 (https://www.python.org/dev/peps/pep-0484/#version-and-platform-checking) we should be able to unify many more stubs.
Merge pull request python#4 from cocoatomo/update-master
srittau commentedon Sep 11, 2018
Here is a list of modules that a simple diff between stdlib/2 and stdlib/3 uncovered (please edit as appropriate):
The packages (marked in italics) need special consideration, since they might contain submodules that don't exist in both versions.
srittau commentedon Oct 23, 2018
Also json, where the stub is currently a module in stdlib/2, but a package in stdlib/3. In the standard library it is a package in both.
hauntsaninja commentedon Jun 11, 2020
Can we close this?
In 2020, it seems like it could be unnecessary burden (and potentially cause errors in py2 stubs by py3-minded people) to merge py2 and py3 stubs using version checks. It's a different matter if the files are identical, but a quick command makes it seem like that's not really the case, see details.
Details
Files which have the same content hash, compare to what's enforced by check_consistent.py
JelleZijlstra commentedon Jun 11, 2020
I agree, this hardly seems worth it any more. Hopefully in the not-too-distant future we can drop support for Python 2 completely.
hauntsaninja commentedon Jun 11, 2020
Okay, sounds good! Closing this and the similar #1427
fix CI (python#4)