2828import traceback
2929import warnings
3030from types import ModuleType
31- from typing import Any , Callable , Dict , Iterator , Optional , overload , Set , Tuple , Type , TypeVar
31+ from typing import Any , Callable , Iterator , overload , TypeVar
3232
3333import numpy as np
3434import pandas as pd
@@ -79,7 +79,7 @@ def cached_method(__func: TFunc) -> TFunc: ...
7979def cached_method (* , maxsize : int = 128 ) -> Callable [[TFunc ], TFunc ]: ...
8080
8181
82- def cached_method (method : Optional [ TFunc ] = None , * , maxsize : int = 128 ) -> Any :
82+ def cached_method (method : TFunc | None = None , * , maxsize : int = 128 ) -> Any :
8383 """Decorator that adds a per-instance LRU cache for a method.
8484
8585 Can be applied with or without parameters to customize the underlying cache:
@@ -195,7 +195,7 @@ def _print(self, expr, **kwargs):
195195 f'\n )'
196196 )
197197
198- if isinstance (value , Dict ):
198+ if isinstance (value , dict ):
199199 return '{' + ',' .join (f"{ proper_repr (k )} : { proper_repr (v )} " for k , v in value .items ()) + '}'
200200
201201 if hasattr (value , "__qualname__" ):
@@ -288,7 +288,7 @@ def _validate_deadline(deadline: str):
288288
289289
290290def deprecated (
291- * , deadline : str , fix : str , name : Optional [ str ] = None
291+ * , deadline : str , fix : str , name : str | None = None
292292) -> Callable [[Callable ], Callable ]:
293293 """Marks a function as deprecated.
294294
@@ -329,9 +329,7 @@ def decorated_func(*args, **kwargs) -> Any:
329329 return decorator
330330
331331
332- def deprecated_class (
333- * , deadline : str , fix : str , name : Optional [str ] = None
334- ) -> Callable [[Type ], Type ]:
332+ def deprecated_class (* , deadline : str , fix : str , name : str | None = None ) -> Callable [[type ], type ]:
335333 """Marks a class as deprecated.
336334
337335 Args:
@@ -348,7 +346,7 @@ def deprecated_class(
348346
349347 _validate_deadline (deadline )
350348
351- def decorator (clazz : Type ) -> Type :
349+ def decorator (clazz : type ) -> type :
352350 clazz_new = clazz .__new__
353351
354352 def patched_new (cls , * args , ** kwargs ):
@@ -378,12 +376,12 @@ def deprecated_parameter(
378376 * ,
379377 deadline : str ,
380378 fix : str ,
381- func_name : Optional [ str ] = None ,
379+ func_name : str | None = None ,
382380 parameter_desc : str ,
383- match : Callable [[Tuple [Any , ...], Dict [str , Any ]], bool ],
384- rewrite : Optional [
385- Callable [[Tuple [Any , ...], Dict [str , Any ]], Tuple [ Tuple [Any , ...], Dict [str , Any ]]]
386- ] = None ,
381+ match : Callable [[tuple [Any , ...], dict [str , Any ]], bool ],
382+ rewrite : (
383+ Callable [[tuple [Any , ...], dict [str , Any ]], tuple [ tuple [Any , ...], dict [str , Any ]]] | None
384+ ) = None ,
387385) -> Callable [[Callable ], Callable ]:
388386 """Marks a function parameter as deprecated.
389387
@@ -447,7 +445,7 @@ async def async_decorated_func(*args, **kwargs) -> Any:
447445 return decorator
448446
449447
450- def deprecate_attributes (module_name : str , deprecated_attributes : Dict [str , Tuple [str , str ]]):
448+ def deprecate_attributes (module_name : str , deprecated_attributes : dict [str , tuple [str , str ]]):
451449 """Replace module with a wrapper that gives warnings for deprecated attributes.
452450
453451 Args:
@@ -586,7 +584,7 @@ def _is_internal(filename: str) -> bool:
586584 return 'importlib' in filename and '_bootstrap' in filename
587585
588586
589- _warned : Set [str ] = set ()
587+ _warned : set [str ] = set ()
590588
591589
592590def _called_from_test () -> bool :
@@ -635,7 +633,7 @@ def __init__(
635633 new_module_name : str ,
636634 old_module_name : str ,
637635 deadline : str ,
638- broken_module_exception : Optional [ BaseException ] ,
636+ broken_module_exception : BaseException | None ,
639637 ):
640638 """An aliasing module finder that uses existing module finders to find a python
641639 module spec and intercept the execution of matching modules.
@@ -763,7 +761,7 @@ def _setup_deprecated_submodule_attribute(
763761 old_parent : str ,
764762 old_child : str ,
765763 deadline : str ,
766- new_module : Optional [ ModuleType ] ,
764+ new_module : ModuleType | None ,
767765):
768766 parent_module = sys .modules [old_parent ]
769767 setattr (parent_module , old_child , new_module )
0 commit comments