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

rewrite six.moves.range #494

Merged
merged 1 commit into from
Jul 24, 2021
Merged

rewrite six.moves.range #494

merged 1 commit into from
Jul 24, 2021

Conversation

MarcoGorelli
Copy link
Contributor

closes #340

@asottile
Copy link
Owner

@MarcoGorelli
Copy link
Contributor Author

I'm not sure I see how - those in REMOVALS are already handled here

'six.moves': ('filter', 'input', 'map', 'range', 'zip'),

and those in REPLACES would require extra imports. E.g. I can't rewrite

six.moves.BaseHTTPServer

to

http.server

because that would require http to have been imported, which as far as I understand is out of scope for pyupgrade

@MarcoGorelli MarcoGorelli force-pushed the six-range branch 2 times, most recently from 70c3447 to ef63665 Compare July 22, 2021 13:11
@asottile
Copy link
Owner

ah I guess I misunderstood what this PR was aiming at, the REPLACES is only for from imports -- can always do that in another PR

Comment on lines 15 to 18
NAMES = {
'range': 'range',
'xrange': 'range',
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since they're currently always range -- this can just be inlined as 'range' right?

@@ -0,0 +1,53 @@
import ast
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this get added to the existing six module ?

@MarcoGorelli
Copy link
Contributor Author

ah I guess I misunderstood what this PR was aiming at, the REPLACES is only for from imports -- can always do that in another PR

ah, so to rewrite e.g.

from six import StringIO
from six.moves.builtins import bool

to

from io import StringIO
from builtins import bool

?

Sure, sounds good, I'll try that in a separate PR (and'll update this one later)

@asottile
Copy link
Owner

ah I guess I misunderstood what this PR was aiming at, the REPLACES is only for from imports -- can always do that in another PR

ah, so to rewrite e.g.

from six import StringIO
from six.moves.builtins import bool

to

from io import StringIO
from builtins import bool

?

Sure, sounds good, I'll try that in a separate PR (and'll update this one later)

yep! though actually the six.moves.builtins ones should just be dropped I imagine

Copy link
Owner

@asottile asottile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asottile asottile merged commit 2f29bd6 into asottile:master Jul 24, 2021
@graingert
Copy link
Contributor

Hyped for Monday already

@MarcoGorelli MarcoGorelli deleted the six-range branch July 24, 2021 09:40
@MarcoGorelli
Copy link
Contributor Author

ah I guess I misunderstood what this PR was aiming at, the REPLACES is only for from imports -- can always do that in another PR

ah, so to rewrite e.g.

from six import StringIO
from six.moves.builtins import bool

to

from io import StringIO
from builtins import bool

?
Sure, sounds good, I'll try that in a separate PR (and'll update this one later)

yep! though actually the six.moves.builtins ones should just be dropped I imagine

Just to clarify - would this just be a duplication of what reorder-python-imports does?

@asottile
Copy link
Owner

for the most part, yeah

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

Successfully merging this pull request may close these issues.

upgrade six.moves.range to range (and other builtins)
3 participants