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

Incorrect rename behavior #95

Open
jiangmf opened this issue Oct 27, 2021 · 0 comments
Open

Incorrect rename behavior #95

jiangmf opened this issue Oct 27, 2021 · 0 comments

Comments

@jiangmf
Copy link

jiangmf commented Oct 27, 2021

When running rename_external on code with both import x and from 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')

>>> 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')
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

1 participant