@@ -236,7 +236,7 @@ def __init__(
236236 @abc .abstractmethod
237237 def matches (
238238 self , cursor_offset : int , line : str , ** kwargs : Any
239- ) -> Optional [ set [str ]] :
239+ ) -> set [str ] | None :
240240 """Returns a list of possible matches given a line and cursor, or None
241241 if this completion type isn't applicable.
242242
@@ -255,7 +255,7 @@ def matches(
255255 raise NotImplementedError
256256
257257 @abc .abstractmethod
258- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
258+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
259259 """Returns a Linepart namedtuple instance or None given cursor and line
260260
261261 A Linepart namedtuple contains a start, stop, and word. None is
@@ -299,7 +299,7 @@ def __init__(
299299
300300 super ().__init__ (True , mode )
301301
302- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
302+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
303303 for completer in self ._completers :
304304 return_value = completer .locate (cursor_offset , line )
305305 if return_value is not None :
@@ -311,7 +311,7 @@ def format(self, word: str) -> str:
311311
312312 def matches (
313313 self , cursor_offset : int , line : str , ** kwargs : Any
314- ) -> Optional [ set [str ]] :
314+ ) -> set [str ] | None :
315315 return_value = None
316316 all_matches = set ()
317317 for completer in self ._completers :
@@ -336,10 +336,10 @@ def __init__(
336336
337337 def matches (
338338 self , cursor_offset : int , line : str , ** kwargs : Any
339- ) -> Optional [ set [str ]] :
339+ ) -> set [str ] | None :
340340 return self .module_gatherer .complete (cursor_offset , line )
341341
342- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
342+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
343343 return lineparts .current_word (cursor_offset , line )
344344
345345 def format (self , word : str ) -> str :
@@ -356,7 +356,7 @@ def __init__(self, mode: AutocompleteModes = AutocompleteModes.SIMPLE):
356356
357357 def matches (
358358 self , cursor_offset : int , line : str , ** kwargs : Any
359- ) -> Optional [ set [str ]] :
359+ ) -> set [str ] | None :
360360 cs = lineparts .current_string (cursor_offset , line )
361361 if cs is None :
362362 return None
@@ -371,7 +371,7 @@ def matches(
371371 matches .add (filename )
372372 return matches
373373
374- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
374+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
375375 return lineparts .current_string (cursor_offset , line )
376376
377377 def format (self , filename : str ) -> str :
@@ -389,9 +389,9 @@ def matches(
389389 cursor_offset : int ,
390390 line : str ,
391391 * ,
392- locals_ : Optional [ dict [str , Any ]] = None ,
392+ locals_ : dict [str , Any ] | None = None ,
393393 ** kwargs : Any ,
394- ) -> Optional [ set [str ]] :
394+ ) -> set [str ] | None :
395395 r = self .locate (cursor_offset , line )
396396 if r is None :
397397 return None
@@ -414,7 +414,7 @@ def matches(
414414 if _few_enough_underscores (r .word .split ("." )[- 1 ], m .split ("." )[- 1 ])
415415 }
416416
417- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
417+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
418418 return lineparts .current_dotted_attribute (cursor_offset , line )
419419
420420 def format (self , word : str ) -> str :
@@ -474,9 +474,9 @@ def matches(
474474 cursor_offset : int ,
475475 line : str ,
476476 * ,
477- locals_ : Optional [ dict [str , Any ]] = None ,
477+ locals_ : dict [str , Any ] | None = None ,
478478 ** kwargs : Any ,
479- ) -> Optional [ set [str ]] :
479+ ) -> set [str ] | None :
480480 if locals_ is None :
481481 return None
482482
@@ -500,7 +500,7 @@ def matches(
500500 else :
501501 return None
502502
503- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
503+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
504504 return lineparts .current_dict_key (cursor_offset , line )
505505
506506 def format (self , match : str ) -> str :
@@ -513,10 +513,10 @@ def matches(
513513 cursor_offset : int ,
514514 line : str ,
515515 * ,
516- current_block : Optional [ str ] = None ,
517- complete_magic_methods : Optional [ bool ] = None ,
516+ current_block : str | None = None ,
517+ complete_magic_methods : bool | None = None ,
518518 ** kwargs : Any ,
519- ) -> Optional [ set [str ]] :
519+ ) -> set [str ] | None :
520520 if (
521521 current_block is None
522522 or complete_magic_methods is None
@@ -531,7 +531,7 @@ def matches(
531531 return None
532532 return {name for name in MAGIC_METHODS if name .startswith (r .word )}
533533
534- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
534+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
535535 return lineparts .current_method_definition_name (cursor_offset , line )
536536
537537
@@ -541,9 +541,9 @@ def matches(
541541 cursor_offset : int ,
542542 line : str ,
543543 * ,
544- locals_ : Optional [ dict [str , Any ]] = None ,
544+ locals_ : dict [str , Any ] | None = None ,
545545 ** kwargs : Any ,
546- ) -> Optional [ set [str ]] :
546+ ) -> set [str ] | None :
547547 """Compute matches when text is a simple name.
548548 Return a list of all keywords, built-in functions and names currently
549549 defined in self.namespace that match.
@@ -571,7 +571,7 @@ def matches(
571571 matches .add (_callable_postfix (val , word ))
572572 return matches if matches else None
573573
574- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
574+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
575575 return lineparts .current_single_word (cursor_offset , line )
576576
577577
@@ -581,9 +581,9 @@ def matches(
581581 cursor_offset : int ,
582582 line : str ,
583583 * ,
584- funcprops : Optional [ inspection .FuncProps ] = None ,
584+ funcprops : inspection .FuncProps | None = None ,
585585 ** kwargs : Any ,
586- ) -> Optional [ set [str ]] :
586+ ) -> set [str ] | None :
587587 if funcprops is None :
588588 return None
589589
@@ -603,7 +603,7 @@ def matches(
603603 )
604604 return matches if matches else None
605605
606- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
606+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
607607 r = lineparts .current_word (cursor_offset , line )
608608 if r and r .word [- 1 ] == "(" :
609609 # if the word ends with a (, it's the parent word with an empty
@@ -614,17 +614,17 @@ def locate(self, cursor_offset: int, line: str) -> Optional[LinePart]:
614614
615615class ExpressionAttributeCompletion (AttrCompletion ):
616616 # could replace attr completion as a more general case with some work
617- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
617+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
618618 return lineparts .current_expression_attribute (cursor_offset , line )
619619
620620 def matches (
621621 self ,
622622 cursor_offset : int ,
623623 line : str ,
624624 * ,
625- locals_ : Optional [ dict [str , Any ]] = None ,
625+ locals_ : dict [str , Any ] | None = None ,
626626 ** kwargs : Any ,
627- ) -> Optional [ set [str ]] :
627+ ) -> set [str ] | None :
628628 if locals_ is None :
629629 locals_ = __main__ .__dict__
630630
@@ -648,26 +648,26 @@ def matches(
648648 class MultilineJediCompletion (BaseCompletionType ): # type: ignore [no-redef]
649649 def matches (
650650 self , cursor_offset : int , line : str , ** kwargs : Any
651- ) -> Optional [ set [str ]] :
651+ ) -> set [str ] | None :
652652 return None
653653
654- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
654+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
655655 return None
656656
657657else :
658658
659659 class MultilineJediCompletion (BaseCompletionType ): # type: ignore [no-redef]
660- _orig_start : Optional [ int ]
660+ _orig_start : int | None
661661
662662 def matches (
663663 self ,
664664 cursor_offset : int ,
665665 line : str ,
666666 * ,
667- current_block : Optional [ str ] = None ,
668- history : Optional [ list [str ]] = None ,
667+ current_block : str | None = None ,
668+ history : list [str ] | None = None ,
669669 ** kwargs : Any ,
670- ) -> Optional [ set [str ]] :
670+ ) -> set [str ] | None :
671671 if (
672672 current_block is None
673673 or history is None
@@ -725,12 +725,12 @@ def get_completer(
725725 cursor_offset : int ,
726726 line : str ,
727727 * ,
728- locals_ : Optional [ dict [str , Any ]] = None ,
729- argspec : Optional [ inspection .FuncProps ] = None ,
730- history : Optional [ list [str ]] = None ,
731- current_block : Optional [ str ] = None ,
732- complete_magic_methods : Optional [ bool ] = None ,
733- ) -> tuple [list [str ], Optional [ BaseCompletionType ] ]:
728+ locals_ : dict [str , Any ] | None = None ,
729+ argspec : inspection .FuncProps | None = None ,
730+ history : list [str ] | None = None ,
731+ current_block : str | None = None ,
732+ complete_magic_methods : bool | None = None ,
733+ ) -> tuple [list [str ], BaseCompletionType | None ]:
734734 """Returns a list of matches and an applicable completer
735735
736736 If no matches available, returns a tuple of an empty list and None
0 commit comments