Open jiangmf opened 2 years ago
When running rename_external on code with both import x and from x import y, the behavior seems to be incorrect.
rename_external
import x
from x import y
In the example below, the generated code will contain an NameError: name 'custom_request' is not defined
NameError: name 'custom_request' is not defined
The expected output should be my_app.custom_request.get('https://google.com')
my_app.custom_request.get('https://google.com')
>>> import pasta >>> from pasta.augment import rename >>> code = """ ... import requests ... from requests import Response ... ... requests.get('https://google.com')""" >>> tree = pasta.parse(code) >>> rename.rename_external(tree, 'requests', 'myapp.custom_request') True >>> print(pasta.dump(tree)) import myapp.custom_request from myapp.custom_request import Response custom_request.get('https://google.com')
When running
rename_external
on code with bothimport x
andfrom x import y
, the behavior seems to be incorrect.In the example below, the generated code will contain an
NameError: name 'custom_request' is not defined
The expected output should be
my_app.custom_request.get('https://google.com')