File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1572,6 +1572,39 @@ def __getattr__(self, attr):
15721572 self .assertNotIn (".append" , matches )
15731573 self .assertNotIn (".keys" , matches )
15741574
1575+ def test_completion_fallback_to_annotation_for_attribute (self ):
1576+ code = textwrap .dedent (
1577+ """
1578+ class StringMethods:
1579+ def a():
1580+ pass
1581+
1582+ class Test:
1583+ str: StringMethods
1584+ def __init__(self):
1585+ self.str = StringMethods()
1586+ def __getattr__(self, name):
1587+ raise AttributeError(f"{name} not found")
1588+ """
1589+ )
1590+
1591+ repro = types .ModuleType ("repro" )
1592+ sys .modules ["repro" ] = repro
1593+ exec (code , repro .__dict__ )
1594+
1595+ ip = get_ipython ()
1596+ ip .user_ns ["repro" ] = repro
1597+ exec ("r = repro.Test()" , ip .user_ns )
1598+
1599+ complete = ip .Completer .complete
1600+ try :
1601+ with evaluation_policy ("limited" ), jedi_status (False ):
1602+ _ , matches = complete (line_buffer = "r.str." )
1603+ self .assertIn (".a" , matches )
1604+ finally :
1605+ sys .modules .pop ("repro" , None )
1606+ ip .user_ns .pop ("r" , None )
1607+
15751608 def test_policy_warnings (self ):
15761609 with self .assertWarns (
15771610 UserWarning ,
You can’t perform that action at this time.
0 commit comments