77import json
88import logging
99import warnings
10- from typing import Any, Dict, List, Optional, Type, TypeVar, Union
10+ from typing import Any, Optional, Type, TypeVar, Union
1111
1212from flask import Response, g, request
1313
@@ -46,16 +46,16 @@ cdef class InputFilter:
4646
4747 def __cinit__ (self ) -> None:
4848 self.methods = make_default_methods()
49- self.fields: Dict [str , FieldModel] = {}
50- self.conditions: List [BaseCondition] = []
51- self.global_filters: List [BaseFilter] = []
52- self.global_validators: List [BaseValidator] = []
53- self.data: Dict [str , Any] = {}
54- self.validated_data: Dict [str , Any] = {}
55- self.errors: Dict [str , str] = {}
49+ self.fields: dict [str , FieldModel] = {}
50+ self.conditions: list [BaseCondition] = []
51+ self.global_filters: list [BaseFilter] = []
52+ self.global_validators: list [BaseValidator] = []
53+ self.data: dict [str , Any] = {}
54+ self.validated_data: dict [str , Any] = {}
55+ self.errors: dict [str , str] = {}
5656 self.model_class: Optional[Type[T]] = None
5757
58- def __init__(self , methods: Optional[List [str]] = None ) -> None:
58+ def __init__(self , methods: Optional[list [str]] = None ) -> None:
5959 if methods is not None:
6060 self.methods.clear()
6161 [self.methods.push_back(method.encode()) for method in methods]
@@ -111,7 +111,7 @@ cdef class InputFilter:
111111 f (Callable): The Flask route function to be decorated.
112112
113113 Returns:
114- Callable[[Any, Any], Union[Response, tuple[Any, Dict [str, Any]]]]: The wrapped function with input validation.
114+ Callable[[Any, Any], Union[Response, tuple[Any, dict [str, Any]]]]: The wrapped function with input validation.
115115 """
116116
117117 def wrapper (
@@ -126,7 +126,7 @@ cdef class InputFilter:
126126 **kwargs: Keyword arguments for the route function.
127127
128128 Returns:
129- Union[Response, tuple[Any, Dict [str, Any]]]: The response from the route function or an error response.
129+ Union[Response, tuple[Any, dict [str, Any]]]: The response from the route function or an error response.
130130 """
131131
132132 cdef InputFilter input_filter = cls ()
@@ -172,7 +172,7 @@ cdef class InputFilter:
172172 return decorator
173173
174174 cpdef object validateData(
175- self , data: Optional[Dict [str , Any]] = None
175+ self , data: Optional[dict [str , Any]] = None
176176 ):
177177 warnings.warn(
178178 " validateData() is deprecated, use validate_data() instead" ,
@@ -182,7 +182,7 @@ cdef class InputFilter:
182182 return self .validate_data(data)
183183
184184 cpdef object validate_data(
185- self , data: Optional[Dict [str , Any]] = None
185+ self , data: Optional[dict [str , Any]] = None
186186 ):
187187 """
188188 Validates input data against defined field rules, including applying
@@ -191,12 +191,12 @@ cdef class InputFilter:
191191 appropriately and conditions are checked after processing.
192192
193193 Args:
194- data (Dict [str, Any]): A dictionary containing the input data to
194+ data (dict [str, Any]): A dictionary containing the input data to
195195 be validated where keys represent field names and values
196196 represent the corresponding data.
197197
198198 Returns:
199- Union[Dict [str, Any], Type[T]]: A dictionary containing the validated data with
199+ Union[dict [str, Any], Type[T]]: A dictionary containing the validated data with
200200 any modifications, default values, or processed values as
201201 per the defined validation rules.
202202
@@ -325,27 +325,27 @@ cdef class InputFilter:
325325 is represented as an instance of the BaseCondition type.
326326
327327 Returns:
328- List [BaseCondition]: A list containing all currently registered
328+ list [BaseCondition]: A list containing all currently registered
329329 instances of BaseCondition.
330330 """
331331 return self .conditions
332332
333- cpdef void setData(self , data: Dict [str , Any]):
333+ cpdef void setData(self , data: dict [str , Any]):
334334 warnings.warn(
335335 " setData() is deprecated, use set_data() instead" ,
336336 DeprecationWarning ,
337337 stacklevel = 2
338338 )
339339 self .set_data(data)
340340
341- cpdef void set_data(self , data: Dict [str , Any]):
341+ cpdef void set_data(self , data: dict [str , Any]):
342342 """
343343 Filters and sets the provided data into the object's internal
344344 storage, ensuring that only the specified fields are considered and
345345 their values are processed through defined filters.
346346
347347 Parameters:
348- data (Dict [str, Any]):
348+ data (dict [str, Any]):
349349 The input dictionary containing key-value pairs where keys
350350 represent field names and values represent the associated
351351 data to be filtered and stored.
@@ -405,7 +405,7 @@ cdef class InputFilter:
405405 can be of various types depending on the object's design.
406406
407407 Returns:
408- Dict [str, Any]: A dictionary containing string keys and their
408+ dict [str, Any]: A dictionary containing string keys and their
409409 corresponding values of any data type.
410410 """
411411 return self .validated_data
@@ -455,7 +455,7 @@ cdef class InputFilter:
455455 the identifiers, and the values are of any data type.
456456
457457 Returns:
458- Dict [str, Any]: A dictionary containing the raw values retrieved.
458+ dict [str, Any]: A dictionary containing the raw values retrieved.
459459 The keys are strings representing the identifiers, and the
460460 values can be of any type, depending on the source
461461 being accessed.
@@ -488,28 +488,28 @@ cdef class InputFilter:
488488 is required, as it does not perform any validations or checks.
489489
490490 Returns:
491- Dict [str, Any]: The unfiltered, raw data retrieved from the
491+ dict [str, Any]: The unfiltered, raw data retrieved from the
492492 data source. The return type may vary based on the
493493 specific implementation of the data source.
494494 """
495495 return self .data
496496
497- cpdef void setUnfilteredData(self , data: Dict [str , Any]):
497+ cpdef void setUnfilteredData(self , data: dict [str , Any]):
498498 warnings.warn(
499499 " setUnfilteredData() is deprecated, use set_unfiltered_data() instead" ,
500500 DeprecationWarning ,
501501 stacklevel = 2
502502 )
503503 self .set_unfiltered_data(data)
504504
505- cpdef void set_unfiltered_data(self , data: Dict [str , Any]):
505+ cpdef void set_unfiltered_data(self , data: dict [str , Any]):
506506 """
507507 Sets unfiltered data for the current instance. This method assigns a
508508 given dictionary of data to the instance for further processing. It
509509 updates the internal state using the provided data.
510510
511511 Parameters:
512- data (Dict [str, Any]): A dictionary containing the unfiltered
512+ data (dict [str, Any]): A dictionary containing the unfiltered
513513 data to be associated with the instance.
514514 """
515515 self .data = data
@@ -585,7 +585,7 @@ cdef class InputFilter:
585585 respective error messages.
586586
587587 Returns:
588- Dict [str, str]: A dictionary containing field names as keys and
588+ dict [str, str]: A dictionary containing field names as keys and
589589 their corresponding error messages as values.
590590 """
591591 return self .errors
@@ -596,9 +596,9 @@ cdef class InputFilter:
596596 required: bool = False ,
597597 default: Any = None ,
598598 fallback: Any = None ,
599- filters: Optional[List [BaseFilter]] = None ,
600- validators: Optional[List [BaseValidator]] = None ,
601- steps: Optional[List [Union[BaseFilter, BaseValidator]]] = None ,
599+ filters: Optional[list [BaseFilter]] = None ,
600+ validators: Optional[list [BaseValidator]] = None ,
601+ steps: Optional[list [Union[BaseFilter, BaseValidator]]] = None ,
602602 external_api: Optional[ExternalApiConfig] = None ,
603603 copy: Optional[str ] = None ,
604604 ) except * :
@@ -615,13 +615,13 @@ cdef class InputFilter:
615615 fallback (Optional[Any]): The fallback value of the field, if
616616 validations fails or field None, although it is required.
617617
618- filters (Optional[List [BaseFilter]]): The filters to apply to
618+ filters (Optional[list [BaseFilter]]): The filters to apply to
619619 the field value.
620620
621- validators (Optional[List [BaseValidator]]): The validators to
621+ validators (Optional[list [BaseValidator]]): The validators to
622622 apply to the field value.
623623
624- steps (Optional[List [Union[BaseFilter, BaseValidator]]]): Allows
624+ steps (Optional[list [Union[BaseFilter, BaseValidator]]]): Allows
625625 to apply multiple filters and validators in a specific order.
626626
627627 external_api (Optional[ExternalApiConfig]): Configuration for an
@@ -699,7 +699,7 @@ cdef class InputFilter:
699699 Retrieve the dictionary of input fields associated with the object.
700700
701701 Returns:
702- Dict [str, FieldModel]: Dictionary containing field names as
702+ dict [str, FieldModel]: Dictionary containing field names as
703703 keys and their corresponding FieldModel instances as values
704704 """
705705 return self .fields
@@ -740,9 +740,9 @@ cdef class InputFilter:
740740 required: bool = False ,
741741 default: Any = None ,
742742 fallback: Any = None ,
743- filters: Optional[List [BaseFilter]] = None ,
744- validators: Optional[List [BaseValidator]] = None ,
745- steps: Optional[List [Union[BaseFilter, BaseValidator]]] = None ,
743+ filters: Optional[list [BaseFilter]] = None ,
744+ validators: Optional[list [BaseValidator]] = None ,
745+ steps: Optional[list [Union[BaseFilter, BaseValidator]]] = None ,
746746 external_api: Optional[ExternalApiConfig] = None ,
747747 copy: Optional[str ] = None ,
748748 ):
@@ -759,13 +759,13 @@ cdef class InputFilter:
759759 fallback (Optional[Any]): The fallback value of the field, if
760760 validations fails or field None, although it is required.
761761
762- filters (Optional[List [BaseFilter]]): The filters to apply to
762+ filters (Optional[list [BaseFilter]]): The filters to apply to
763763 the field value.
764764
765- validators (Optional[List [BaseValidator]]): The validators to
765+ validators (Optional[list [BaseValidator]]): The validators to
766766 apply to the field value.
767767
768- steps (Optional[List [Union[BaseFilter, BaseValidator]]]): Allows
768+ steps (Optional[list [Union[BaseFilter, BaseValidator]]]): Allows
769769 to apply multiple filters and validators in a specific order.
770770
771771 external_api (Optional[ExternalApiConfig]): Configuration for an
@@ -819,7 +819,7 @@ cdef class InputFilter:
819819 all fields during data processing.
820820
821821 Returns:
822- List [BaseFilter]: A list of global filters.
822+ list [BaseFilter]: A list of global filters.
823823 """
824824 return self .global_filters
825825
@@ -907,7 +907,7 @@ cdef class InputFilter:
907907 raw validated data.
908908
909909 Returns:
910- Union[Dict [str, Any], T]: The serialized data.
910+ Union[dict [str, Any], T]: The serialized data.
911911 """
912912 if self .model_class is None :
913913 return self .validated_data
@@ -949,6 +949,6 @@ cdef class InputFilter:
949949 to all fields during validation.
950950
951951 Returns:
952- List [BaseValidator]: A list of global validators.
952+ list [BaseValidator]: A list of global validators.
953953 """
954954 return self .global_validators
0 commit comments