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

The name for the variables within a list comprehension are incorrect #1944

Open
misrasaurabh1 opened this issue Jul 6, 2023 · 4 comments
Open

Comments

@misrasaurabh1
Copy link

For the script below

def pig_latin(text):
    translated_words = [translate(word) for word in words]

Running s.get_names(all_scopes=True, references=True) on it shows the variables within the list comprehension with full names such as __main__.translate and __main__.word rather than the expected __main__.pig_latin.translate

This causes these variable to be in effect be hidden from the function scope, which breaks functionality of static analysis tools. Is the current behavior intended? If so, then would love some signal that the functions and variables belongs to the pig_latin function. If not, would love a fix to the names of the list comprehension variables.

@davidhalter
Copy link
Owner

What is the qualified name of translated_words?

@misrasaurabh1
Copy link
Author

translated_words seems to have the right name of full_name='__main__.pig_latin.translated_words'
List comprehension variable translate and word still have the wrong names though.

@davidhalter
Copy link
Owner

I'm a bit unsure what to do here. The correct name for translate would probably be something else entirely and the correct name for word would probably be __main__.pig_latin.<comprehension>.word. So if you fix that I'm happy to merge a PR, but I'm still a bit unhappy with how translate is handled.

@misrasaurabh1
Copy link
Author

@davidhalter Even though I am passionate about jedi, I am currently busy with some other projects so won't be able to contribute here.
In any case would love it if you or some one else could implement the __main__.pig_latin.<comprehension_1>.word solution. This will prevent Jedi from being broken for list comprehensions, which is a key use-case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants