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
Get reference in type annotation #1898
Comments
Can you maybe send the full reproduction code? I feel like you removed the jedi calls. |
You are right, a silly copy-paste error. Here is the updated script and output. At the same time, I noticed the part about f-string I mentioned above was actually fixed in 0.18.2, so there is actually only one issue left which is the reference in a type annotation give as a string. import jedi
source = '''
class Foo:
def return_me(self) -> "Foo":
return self
'''
script=jedi.Script(code=source)
for ref in script.get_references(line=2, column=7):
print(ref) Output
|
Yes, the issue with the references is unfortunate, but I'm not sure this is very easy. I would probably argue that people should just use You could try to scan for all functions in a file and then check all annotations and parse those (if they are strings), look for the name and try to resolve it. It's probably not extremely easy, but definitely possible. |
I agree with you the use for |
Jedi seems to not pick up reference that are in type annotation or in f-string. This creates issue when using rename has to reference are not changed.
This snippet prints only one reference when it should find three.
Output:
I don't know if that is conscious choice, but it would be able to pick those references. I'd be happy to help, maybe by coding a failing test first, if someone can point me where it should go.
The text was updated successfully, but these errors were encountered: