Skip to content
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

Remove call to future standard_library.install_aliases() #24

Open
matthewhampton opened this issue Mar 9, 2020 · 2 comments
Open

Remove call to future standard_library.install_aliases() #24

matthewhampton opened this issue Mar 9, 2020 · 2 comments

Comments

@matthewhampton
Copy link
Contributor

This is not safe to use in a library.

Also, please review the use of future in this library to make sure it is conservative enough not to cause trouble for other users of the library.

(or maybe consider modernize instead)

See #20 (comment)

@matthewhampton matthewhampton changed the title Remove install_aliases Remove call to future standard_library.install_aliases() Mar 9, 2020
@matthewhampton matthewhampton mentioned this issue Mar 9, 2020
1 task
@yaseen-mowzer-hexagon
Copy link
Contributor

As far as I can tell modernize is just a 2to3 fixer like futurize, but unlike python-future doesn't backport modules from python 3 to python 2. One has to use modernize with six in order to write code that is valid python 2 and python 3.

Since we are already have futurized the code, reverting it back and then modernizing it seems like a waste of time, especially since the changes that futurize made were pretty conservative (See f86c386 and ea940f8) So I suggest we ignore modernize for now.

The question becomes then, should we use python-future or six? Future without install_aliases (but with from builtins import *) seems reasonably conservative, while allowing one to write clean Python 3 looking code. Six forces one to use awkward constructs such as six.text_type. Compare this to future where you can just use str.

The only thing we'll miss from future if we don't use install_aliases is these modules https://python-future.org/standard_library_imports.html#aliased-imports. (The other modules have been backported and do not have conflicting names in Python 2 so they don't need to install aliases).

The worse thing that we will do to other modules if we use future is that we may return future.types.new* instead of native python types. This shouldn't be much of a problem since python uses duck-typing, but if it does cause problems we could always call native on the values we return to ensure that we don't leak objects with weird types.

Given this I think it's better if we continue to use future, without install_aliases.

@matthewhampton
Copy link
Contributor Author

Sounds reasonable to me!

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