55from typing import (
66 Any ,
77 Callable ,
8- Dict ,
9- Iterable ,
108 NamedTuple ,
119 Optional ,
12- Tuple ,
13- Type ,
1410 TypeVar ,
1511 Union ,
1612 no_type_check ,
1713)
14+ from collections .abc import Iterable
1815
1916import pandas as pd
2017from pandera .api .function_dispatch import Dispatcher
@@ -36,8 +33,8 @@ class CheckResult(NamedTuple):
3633 pd .core .groupby .generic .DataFrameGroupBy ,
3734]
3835
39- SeriesCheckObj = Union [pd .Series , Dict [str , pd .Series ]]
40- DataFrameCheckObj = Union [pd .DataFrame , Dict [str , pd .DataFrame ]]
36+ SeriesCheckObj = Union [pd .Series , dict [str , pd .Series ]]
37+ DataFrameCheckObj = Union [pd .DataFrame , dict [str , pd .DataFrame ]]
4138
4239
4340_T = TypeVar ("_T" , bound = "BaseCheck" )
@@ -46,15 +43,15 @@ class CheckResult(NamedTuple):
4643class MetaCheck (type ): # pragma: no cover
4744 """Check metaclass."""
4845
49- BACKEND_REGISTRY : Dict [ Tuple [ Type , Type ], Type [BaseCheckBackend ]] = (
46+ BACKEND_REGISTRY : dict [ tuple [ type , type ], type [BaseCheckBackend ]] = (
5047 {}
5148 ) # noqa
5249 """Registry of check backends implemented for specific data objects."""
5350
54- CHECK_FUNCTION_REGISTRY : Dict [str , Dispatcher ] = {} # noqa
51+ CHECK_FUNCTION_REGISTRY : dict [str , Dispatcher ] = {} # noqa
5552 """Built-in check function registry."""
5653
57- REGISTERED_CUSTOM_CHECKS : Dict [str , Callable ] = {} # noqa
54+ REGISTERED_CUSTOM_CHECKS : dict [str , Callable ] = {} # noqa
5855 """User-defined custom checks."""
5956
6057 def __getattr__ (cls , name : str ) -> Any :
@@ -85,7 +82,7 @@ def __dir__(cls) -> Iterable[str]:
8582 # see https://mypy.readthedocs.io/en/stable/metaclasses.html#gotchas-and-limitations-of-metaclass-support
8683 # pylint: enable=line-too-long
8784 @no_type_check
88- def __contains__ (cls : Type [_T ], item : Union [_T , str ]) -> bool :
85+ def __contains__ (cls : type [_T ], item : Union [_T , str ]) -> bool :
8986 """Allow lookups for registered checks."""
9087 if isinstance (item , cls ):
9188 name = item .name
@@ -102,7 +99,7 @@ def __init__(
10299 self ,
103100 name : Optional [str ] = None ,
104101 error : Optional [str ] = None ,
105- statistics : Optional [Dict [str , Any ]] = None ,
102+ statistics : Optional [dict [str , Any ]] = None ,
106103 ):
107104 self .name = name
108105 self .error = error
@@ -136,7 +133,7 @@ def from_builtin_check_name(
136133 name : str ,
137134 init_kwargs ,
138135 error : Union [str , Callable ],
139- statistics : Optional [Dict [str , Any ]] = None ,
136+ statistics : Optional [dict [str , Any ]] = None ,
140137 ** check_kwargs ,
141138 ):
142139 """Create a Check object from a built-in check's name."""
@@ -156,13 +153,13 @@ def from_builtin_check_name(
156153 )
157154
158155 @classmethod
159- def register_backend (cls , type_ : Type , backend : Type [BaseCheckBackend ]):
156+ def register_backend (cls , type_ : type , backend : type [BaseCheckBackend ]):
160157 """Register a backend for the specified type."""
161158 if (cls , type_ ) not in cls .BACKEND_REGISTRY :
162159 cls .BACKEND_REGISTRY [(cls , type_ )] = backend
163160
164161 @classmethod
165- def get_backend (cls , check_obj : Any ) -> Type [BaseCheckBackend ]:
162+ def get_backend (cls , check_obj : Any ) -> type [BaseCheckBackend ]:
166163 """Get the backend associated with the type of ``check_obj`` ."""
167164
168165 check_obj_cls = type (check_obj )
0 commit comments