-
-
Notifications
You must be signed in to change notification settings - Fork 525
Open
Description
Bug Description
Hi there,
I hope this finds you well. I've discovered that JEDI currently doesn't recognize Self type hints from both typing and typing_extensions modules when used as method return types.
Bug Description
JEDI fails to recognize Self type hints from both typing and typing_extensions modules when used as method return types.
Test Case
import jedi
test_code = '''
import typing
import typing_extensions
class UILayout:
def method_typing_self(self) -> typing.Self:
pass
def method_typing_ext_self(self) -> typing_extensions.Self:
pass
def method_string_self(self) -> 'UILayout':
pass
layout = UILayout()
result1 = layout.method_typing_self()
result2 = layout.method_typing_ext_self()
result3 = layout.method_string_self()
'''
script = jedi.Script(code=test_code)
print("typing.Self:", [inf.description for inf in script.infer(line=14, column=0)])
print("typing_extensions.Self:", [inf.description for inf in script.infer(line=15, column=0)])
print("String annotation:", [inf.description for inf in script.infer(line=16, column=0)])Expected vs Actual Results
Expected: All three should return ['instance UILayout']
Actual:
typing.Self: []
typing_extensions.Self: []
String annotation: ['instance UILayout'] #✅
Environment
JEDI version: [0.19.2]
Python version: [3.11.7]
Impact
This affects autocompletion experience in IDEs when using the standardized Self type (PEP 673). As a temporary workaround, string annotations can be used to achieve proper type inference.
Metadata
Metadata
Assignees
Labels
No labels