33from copy import copy
44from functools import wraps
55from types import MethodType
6- from typing import Any , Callable , List , Optional , Protocol , Tuple , TypeVar , Union
6+ from typing import Any , Callable , Optional , Protocol , TypeVar , Union
77
88from .method import Method
99from .resolver import AmbiguousLookupError , NotFoundLookupError , Resolver
2020# `typing.Self` is available for Python 3.11 and higher.
2121try : # pragma: specific no cover 3.11
2222 from typing import Self
23- except ImportError : # pragma: specific no cover 3.8 3.9 3. 10
23+ except ImportError : # pragma: specific no cover 3.10
2424 Self = TypeVar ("Self" , bound = "Function" )
2525
2626SomeExceptionType = TypeVar ("SomeExceptionType" , bound = Exception )
@@ -96,12 +96,12 @@ def __init__(
9696 self ._warn_redefinition = warn_redefinition
9797
9898 # Initialise pending and resolved methods.
99- self ._pending : List [ Tuple [Callable , Optional [Signature ], int ]] = []
99+ self ._pending : list [ tuple [Callable , Optional [Signature ], int ]] = []
100100 self ._resolver = Resolver (
101101 self .__name__ ,
102102 warn_redefinition = self ._warn_redefinition ,
103103 )
104- self ._resolved : List [ Tuple [Callable , Signature , int ]] = []
104+ self ._resolved : list [ tuple [Callable , Signature , int ]] = []
105105
106106 @property
107107 def owner (self ):
@@ -125,7 +125,7 @@ def __doc__(self) -> Optional[str]:
125125 """
126126 try :
127127 self ._resolve_pending_registrations ()
128- except NameError : # pragma: specific no cover 3.7 3.8 3. 9
128+ except NameError : # pragma: specific no cover 3.9
129129 # When `staticmethod` is combined with
130130 # `from __future__ import annotations`, in Python 3.10 and higher
131131 # `staticmethod` will attempt to inherit `__doc__` (see
@@ -176,7 +176,7 @@ def __doc__(self, value: str) -> None:
176176 self ._doc = value if value else ""
177177
178178 @property
179- def methods (self ) -> List [Signature ]:
179+ def methods (self ) -> list [Signature ]:
180180 """list[:class:`.signature.Signature`]: All available methods."""
181181 self ._resolve_pending_registrations ()
182182 return self ._resolver .methods
@@ -199,7 +199,7 @@ def dispatch(
199199 return self
200200
201201 def dispatch_multi (
202- self : Self , * signatures : Union [Signature , Tuple [TypeHint , ...]]
202+ self : Self , * signatures : Union [Signature , tuple [TypeHint , ...]]
203203 ) -> Callable [[Callable ], Self ]:
204204 """Decorator to extend the function with multiple signatures at once.
205205
@@ -296,8 +296,8 @@ def _resolve_pending_registrations(self) -> None:
296296 self .clear_cache (reregister = False )
297297
298298 def resolve_method (
299- self , target : Union [Tuple [object , ...], Signature ]
300- ) -> Tuple [Callable , TypeHint ]:
299+ self , target : Union [tuple [object , ...], Signature ]
300+ ) -> tuple [Callable , TypeHint ]:
301301 """Find the method and return type for arguments.
302302
303303 Args:
@@ -336,7 +336,7 @@ def resolve_method(
336336
337337 def _handle_not_found_lookup_error (
338338 self , ex : NotFoundLookupError
339- ) -> Tuple [Callable , TypeHint ]:
339+ ) -> tuple [Callable , TypeHint ]:
340340 if not self .owner :
341341 # Not in a class. Nothing we can do.
342342 raise ex from None
@@ -384,9 +384,9 @@ def __call__(self, *args, **kw_args):
384384
385385 def _resolve_method_with_cache (
386386 self ,
387- args : Union [Tuple [object , ...], Signature , None ] = None ,
388- types : Optional [Tuple [TypeHint , ...]] = None ,
389- ) -> Tuple [Callable , TypeHint ]:
387+ args : Union [tuple [object , ...], Signature , None ] = None ,
388+ types : Optional [tuple [TypeHint , ...]] = None ,
389+ ) -> tuple [Callable , TypeHint ]:
390390 if args is None and types is None :
391391 raise ValueError (
392392 "Arguments `args` and `types` cannot both be `None`. "
@@ -525,7 +525,7 @@ def wrapped_method(*args, **kw_args):
525525 return wrapped_method
526526
527527 @property
528- def methods (self ) -> List [Signature ]:
528+ def methods (self ) -> list [Signature ]:
529529 """list[:class:`.signature.Signature`]: All available methods."""
530530 return self ._f .methods
531531
0 commit comments