asottile / pyupgrade

A tool (and pre-commit hook) to automatically upgrade syntax for newer versions of the language.
MIT License
3.58k stars 182 forks source link

pyupgrade only rewrites six as-import partly #895

Closed spaceone closed 1 year ago

spaceone commented 1 year ago

pyupgrade only rewrites six as-import partly

-from six.moves import http_client as httplib, urllib_error, urllib_request as urllib2
+from six.moves import urllib_error, urllib_request as urllib2
+from http import client as httplib

expected:

-from six.moves import http_client as httplib, urllib_error, urllib_request as urllib2
+from urllib import error as urllib_error, 
+from urllib import request as urllib2
+from http import client as httplib
asottile commented 1 year ago

there's no urllib_error exact replacement so it cannot be done safely without introducing as. this is intentional as introducing as is kind of ugly and doesn't make the code better just different