-
Notifications
You must be signed in to change notification settings - Fork 432
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
Replace 2to3 with six #364
Conversation
I feel pretty underqualified to comment on this, but it looks pretty good as far as I can tell. I did some googling and found this page on the Python Wiki which suggests that six should be used only when necessary, but I think that's what you've tried to do here. This cheat sheet is pretty helpful in trying to figure out when it's necessary to invoke If you feel pretty confident that this is the right direction, I'd trust your judgement. The idea of Regarding the new dependency: it looks like the project has been specifically designed to be easily vendorable into your project and I notice that some big projects like Django have done just that. I'm not sure what the right direction on that one would be, but we could consider doing that as well if we're worried about a new dependency. |
Very good point about vendoring six. I'd actually be in favor of that since it's just one file to add. We may even want to write our own compatibility layer by stealing just the bits that we use from six as there aren't that many. For this PR I took a conservative approach so as not to modify existing behavior. Basically what I did was use If you use
I'm fairly sure we could do a lot of improvements to string handling and start using Unicode ~everywhere, but we'd need to be careful about that and maybe release with a major version bump, so I left that part out for now. |
Cool makes sense to me.
Clever! Sure beats running the Travis build over and over again. But yeah, I'm pretty peaceful with the chance if you're confident it's the right direction. I'll leave the merge decision up to you. |
ptal @brandur-stripe |
Good call. I definitely want to be able to just copy and paste new versions to aid with updates.
Yep, that looks reasonable to me. Thanks for reading all those compatibility notes so that we can build an informed design. Cool, this looks good to me then! Pulling it in. |
Released as 1.73.0. |
r? @brandur-stripe
cc @stripe/api-libraries
This PR replaces
2to3
withsix
to make the library's code directly compatible with both Python 2 and 3. I'm not saying we should merge this as is but I want to at least start a discussion:This adds a new dependency. However,
six
is one of the most popular and ubiquitous Python modules and there's a good chance our users will already have it installed.Arguably, this is just trading one magic layer for another. However, I think that it is much easier to reason around
six
than around2to3
because with the latter, when running under Python 3, the code that is being executed is not the code that you're seeing.Additionally (and my main motivation if I'm being honest), once we stop using
2to3
we will be able to move the tests out of the main library's directory and into a dedicated directory that will not be installed when the library is packaged as a wheel.