-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Split stdlib into Python 2 and 3 versions #5442
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
Conversation
All new files in stdlib/@python2 are straight copies of the corresponding files in stdlib.
|
One final thought: This could make type checker logic for where to look for Python 2 stubs a bit easier, as they don't even need to look at |
It was called ConfigParser in Python 2. Split out from python#5442.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
4 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
JukkaL
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall I like this idea. I've seen changes to combined Python 2/3 stubs break them on Python 2 because somebody forgot to use Text, and this should help with that, in particular. I also agree with the other motivating factors.
Afterwards, we could also replace Text types in Python 3 stubs with str, making the stubs a bit cleaner.
| print_function: _Feature | ||
| unicode_literals: _Feature | ||
| with_statement: _Feature | ||
| if sys.version_info >= (3, 0): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These Python 3 version checks might be worth removing at some point, at least if we can script it easily.
It was called ConfigParser in Python 2. Split out from #5442.
|
I'm on board with doing this now. #5445 is another example of how the Python 2 stubs are hard to maintain correctly if we don't keep them separate. Hopefully in a couple of years we can drop Python 2 stubs completely. |
This comment has been minimized.
This comment has been minimized.
|
I generally don't like pull requests that add a lot of code, but I see the rationale and I think this is a good idea. The usual arguments for why copy/pasta is bad don't really apply here, as the intent is to not port every fix to Python 2. |
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
|
Before merging, I think we should ask what other active maintainers think about this, e.g. @hauntsaninja and @ilevkivskyi. |
|
LGTM. You may double-check auto-uploader will be not broken by this (although I am 99% sure it shouldn't). |
|
Since this is only about the stdlib at the moment, it shouldn't affect the auto-uploader. That said, we could think about doing this to third-party libs as well, but I don't think it's as important. |
|
I'm fine with this. |
|
All maintainers are in favor, tests pass, if no one beats me to it, I'm going to merge it in a bit. |
All new files in stdlib/@python2 are straight copies of the corresponding files in stdlib. Edit: With one change:
genericpath.pyigained a new# type: ignore, since mypy started to complain about it. Edit 2: I also updatedCONTRIBUTING.md.I know that this a controversial change, which is why I marked this PR as a draft for now as I would like to reach a consensus before merging this. Here's my reasoning (which is partly a repeat of the arguments I made in #5049):
Let me prefix this that I personally haven't worked with Python 2 for quite a while and never with typing support, so that my reasoning could make some very wrong assumptions. But I think that Python 2 and 3 stubs have quite different requirements:
These are the background why I think splitting the stubs makes sense:
strinstead ofTextor using typing features not available for Python 2.Text) and Python 2 branches in Python 3 stubs, making the stubs clearer and easier to maintain in general.VERSIONSand the@python2directory.Finally, by doing this "big split" once and without any other changes has the advantage of clarity in the commit history over our current practice of splitting ad-hoc when changes are made for a stub.
See also #5049 for previous discussion.
This is the script I used to split the stubs: