@@ -236,7 +236,7 @@ def __init__(
236
236
@abc .abstractmethod
237
237
def matches (
238
238
self , cursor_offset : int , line : str , ** kwargs : Any
239
- ) -> Optional [ set [str ]] :
239
+ ) -> set [str ] | None :
240
240
"""Returns a list of possible matches given a line and cursor, or None
241
241
if this completion type isn't applicable.
242
242
@@ -255,7 +255,7 @@ def matches(
255
255
raise NotImplementedError
256
256
257
257
@abc .abstractmethod
258
- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
258
+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
259
259
"""Returns a Linepart namedtuple instance or None given cursor and line
260
260
261
261
A Linepart namedtuple contains a start, stop, and word. None is
@@ -299,7 +299,7 @@ def __init__(
299
299
300
300
super ().__init__ (True , mode )
301
301
302
- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
302
+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
303
303
for completer in self ._completers :
304
304
return_value = completer .locate (cursor_offset , line )
305
305
if return_value is not None :
@@ -311,7 +311,7 @@ def format(self, word: str) -> str:
311
311
312
312
def matches (
313
313
self , cursor_offset : int , line : str , ** kwargs : Any
314
- ) -> Optional [ set [str ]] :
314
+ ) -> set [str ] | None :
315
315
return_value = None
316
316
all_matches = set ()
317
317
for completer in self ._completers :
@@ -336,10 +336,10 @@ def __init__(
336
336
337
337
def matches (
338
338
self , cursor_offset : int , line : str , ** kwargs : Any
339
- ) -> Optional [ set [str ]] :
339
+ ) -> set [str ] | None :
340
340
return self .module_gatherer .complete (cursor_offset , line )
341
341
342
- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
342
+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
343
343
return lineparts .current_word (cursor_offset , line )
344
344
345
345
def format (self , word : str ) -> str :
@@ -356,7 +356,7 @@ def __init__(self, mode: AutocompleteModes = AutocompleteModes.SIMPLE):
356
356
357
357
def matches (
358
358
self , cursor_offset : int , line : str , ** kwargs : Any
359
- ) -> Optional [ set [str ]] :
359
+ ) -> set [str ] | None :
360
360
cs = lineparts .current_string (cursor_offset , line )
361
361
if cs is None :
362
362
return None
@@ -371,7 +371,7 @@ def matches(
371
371
matches .add (filename )
372
372
return matches
373
373
374
- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
374
+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
375
375
return lineparts .current_string (cursor_offset , line )
376
376
377
377
def format (self , filename : str ) -> str :
@@ -389,9 +389,9 @@ def matches(
389
389
cursor_offset : int ,
390
390
line : str ,
391
391
* ,
392
- locals_ : Optional [ dict [str , Any ]] = None ,
392
+ locals_ : dict [str , Any ] | None = None ,
393
393
** kwargs : Any ,
394
- ) -> Optional [ set [str ]] :
394
+ ) -> set [str ] | None :
395
395
r = self .locate (cursor_offset , line )
396
396
if r is None :
397
397
return None
@@ -414,7 +414,7 @@ def matches(
414
414
if _few_enough_underscores (r .word .split ("." )[- 1 ], m .split ("." )[- 1 ])
415
415
}
416
416
417
- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
417
+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
418
418
return lineparts .current_dotted_attribute (cursor_offset , line )
419
419
420
420
def format (self , word : str ) -> str :
@@ -474,9 +474,9 @@ def matches(
474
474
cursor_offset : int ,
475
475
line : str ,
476
476
* ,
477
- locals_ : Optional [ dict [str , Any ]] = None ,
477
+ locals_ : dict [str , Any ] | None = None ,
478
478
** kwargs : Any ,
479
- ) -> Optional [ set [str ]] :
479
+ ) -> set [str ] | None :
480
480
if locals_ is None :
481
481
return None
482
482
@@ -500,7 +500,7 @@ def matches(
500
500
else :
501
501
return None
502
502
503
- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
503
+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
504
504
return lineparts .current_dict_key (cursor_offset , line )
505
505
506
506
def format (self , match : str ) -> str :
@@ -513,10 +513,10 @@ def matches(
513
513
cursor_offset : int ,
514
514
line : str ,
515
515
* ,
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 ,
518
518
** kwargs : Any ,
519
- ) -> Optional [ set [str ]] :
519
+ ) -> set [str ] | None :
520
520
if (
521
521
current_block is None
522
522
or complete_magic_methods is None
@@ -531,7 +531,7 @@ def matches(
531
531
return None
532
532
return {name for name in MAGIC_METHODS if name .startswith (r .word )}
533
533
534
- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
534
+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
535
535
return lineparts .current_method_definition_name (cursor_offset , line )
536
536
537
537
@@ -541,9 +541,9 @@ def matches(
541
541
cursor_offset : int ,
542
542
line : str ,
543
543
* ,
544
- locals_ : Optional [ dict [str , Any ]] = None ,
544
+ locals_ : dict [str , Any ] | None = None ,
545
545
** kwargs : Any ,
546
- ) -> Optional [ set [str ]] :
546
+ ) -> set [str ] | None :
547
547
"""Compute matches when text is a simple name.
548
548
Return a list of all keywords, built-in functions and names currently
549
549
defined in self.namespace that match.
@@ -571,7 +571,7 @@ def matches(
571
571
matches .add (_callable_postfix (val , word ))
572
572
return matches if matches else None
573
573
574
- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
574
+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
575
575
return lineparts .current_single_word (cursor_offset , line )
576
576
577
577
@@ -581,9 +581,9 @@ def matches(
581
581
cursor_offset : int ,
582
582
line : str ,
583
583
* ,
584
- funcprops : Optional [ inspection .FuncProps ] = None ,
584
+ funcprops : inspection .FuncProps | None = None ,
585
585
** kwargs : Any ,
586
- ) -> Optional [ set [str ]] :
586
+ ) -> set [str ] | None :
587
587
if funcprops is None :
588
588
return None
589
589
@@ -603,7 +603,7 @@ def matches(
603
603
)
604
604
return matches if matches else None
605
605
606
- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
606
+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
607
607
r = lineparts .current_word (cursor_offset , line )
608
608
if r and r .word [- 1 ] == "(" :
609
609
# 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]:
614
614
615
615
class ExpressionAttributeCompletion (AttrCompletion ):
616
616
# 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 :
618
618
return lineparts .current_expression_attribute (cursor_offset , line )
619
619
620
620
def matches (
621
621
self ,
622
622
cursor_offset : int ,
623
623
line : str ,
624
624
* ,
625
- locals_ : Optional [ dict [str , Any ]] = None ,
625
+ locals_ : dict [str , Any ] | None = None ,
626
626
** kwargs : Any ,
627
- ) -> Optional [ set [str ]] :
627
+ ) -> set [str ] | None :
628
628
if locals_ is None :
629
629
locals_ = __main__ .__dict__
630
630
@@ -648,26 +648,26 @@ def matches(
648
648
class MultilineJediCompletion (BaseCompletionType ): # type: ignore [no-redef]
649
649
def matches (
650
650
self , cursor_offset : int , line : str , ** kwargs : Any
651
- ) -> Optional [ set [str ]] :
651
+ ) -> set [str ] | None :
652
652
return None
653
653
654
- def locate (self , cursor_offset : int , line : str ) -> Optional [ LinePart ] :
654
+ def locate (self , cursor_offset : int , line : str ) -> LinePart | None :
655
655
return None
656
656
657
657
else :
658
658
659
659
class MultilineJediCompletion (BaseCompletionType ): # type: ignore [no-redef]
660
- _orig_start : Optional [ int ]
660
+ _orig_start : int | None
661
661
662
662
def matches (
663
663
self ,
664
664
cursor_offset : int ,
665
665
line : str ,
666
666
* ,
667
- current_block : Optional [ str ] = None ,
668
- history : Optional [ list [str ]] = None ,
667
+ current_block : str | None = None ,
668
+ history : list [str ] | None = None ,
669
669
** kwargs : Any ,
670
- ) -> Optional [ set [str ]] :
670
+ ) -> set [str ] | None :
671
671
if (
672
672
current_block is None
673
673
or history is None
@@ -725,12 +725,12 @@ def get_completer(
725
725
cursor_offset : int ,
726
726
line : str ,
727
727
* ,
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 ]:
734
734
"""Returns a list of matches and an applicable completer
735
735
736
736
If no matches available, returns a tuple of an empty list and None
0 commit comments