@@ -418,25 +418,27 @@ def locate(self, cursor_offset: int, line: str) -> Optional[LinePart]:
418
418
def format (self , word : str ) -> str :
419
419
return _after_last_dot (word )
420
420
421
- def attr_matches (self , text : str , namespace : Dict [str , Any ]) -> List :
421
+ def attr_matches (
422
+ self , text : str , namespace : Dict [str , Any ]
423
+ ) -> Iterator [str ]:
422
424
"""Taken from rlcompleter.py and bent to my will."""
423
425
424
426
m = self .attr_matches_re .match (text )
425
427
if not m :
426
- return []
428
+ return ( _ for _ in ())
427
429
428
430
expr , attr = m .group (1 , 3 )
429
431
if expr .isdigit ():
430
432
# Special case: float literal, using attrs here will result in
431
433
# a SyntaxError
432
- return []
434
+ return ( _ for _ in ())
433
435
try :
434
436
obj = safe_eval (expr , namespace )
435
437
except EvaluationError :
436
- return []
438
+ return ( _ for _ in ())
437
439
return self .attr_lookup (obj , expr , attr )
438
440
439
- def attr_lookup (self , obj : Any , expr : str , attr : str ) -> List :
441
+ def attr_lookup (self , obj : Any , expr : str , attr : str ) -> Iterator [ str ] :
440
442
"""Second half of attr_matches."""
441
443
words = self .list_attributes (obj )
442
444
if inspection .hasattr_safe (obj , "__class__" ):
@@ -449,12 +451,12 @@ def attr_lookup(self, obj: Any, expr: str, attr: str) -> List:
449
451
except ValueError :
450
452
pass
451
453
452
- matches = []
453
454
n = len (attr )
454
- for word in words :
455
- if self .method_match (word , n , attr ) and word != "__builtins__" :
456
- matches .append (f"{ expr } .{ word } " )
457
- return matches
455
+ return (
456
+ f"{ expr } .{ word } "
457
+ for word in words
458
+ if self .method_match (word , n , attr ) and word != "__builtins__"
459
+ )
458
460
459
461
def list_attributes (self , obj : Any ) -> List [str ]:
460
462
# TODO: re-implement dir without AttrCleaner here
0 commit comments