mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
build(deps): bump mypy from 0.920 to 0.930 (#3573)
* build(deps): bump mypy from 0.920 to 0.930 * fix: avoid mypy plugin crash Due to https://github.com/python/mypy/pull/11332, mypy would crash because `__builtins__` is not part of `ctx.api` modules, `builtins` is * fix tests
This commit is contained in:
@@ -54,7 +54,7 @@ def validator(
|
||||
check_fields: bool = True,
|
||||
whole: bool = None,
|
||||
allow_reuse: bool = False,
|
||||
) -> Callable[[AnyCallable], classmethod]:
|
||||
) -> Callable[[AnyCallable], classmethod]: # type: ignore[type-arg]
|
||||
"""
|
||||
Decorate methods on the class indicating that they should be used to validate fields
|
||||
:param fields: which field(s) the method should be called on
|
||||
@@ -81,7 +81,7 @@ def validator(
|
||||
assert each_item is False, '"each_item" and "whole" conflict, remove "whole"'
|
||||
each_item = not whole
|
||||
|
||||
def dec(f: AnyCallable) -> classmethod:
|
||||
def dec(f: AnyCallable) -> classmethod: # type: ignore[type-arg]
|
||||
f_cls = _prepare_validator(f, allow_reuse)
|
||||
setattr(
|
||||
f_cls,
|
||||
@@ -97,20 +97,20 @@ def validator(
|
||||
|
||||
|
||||
@overload
|
||||
def root_validator(_func: AnyCallable) -> classmethod:
|
||||
def root_validator(_func: AnyCallable) -> classmethod: # type: ignore[type-arg]
|
||||
...
|
||||
|
||||
|
||||
@overload
|
||||
def root_validator(
|
||||
*, pre: bool = False, allow_reuse: bool = False, skip_on_failure: bool = False
|
||||
) -> Callable[[AnyCallable], classmethod]:
|
||||
) -> Callable[[AnyCallable], classmethod]: # type: ignore[type-arg]
|
||||
...
|
||||
|
||||
|
||||
def root_validator(
|
||||
_func: Optional[AnyCallable] = None, *, pre: bool = False, allow_reuse: bool = False, skip_on_failure: bool = False
|
||||
) -> Union[classmethod, Callable[[AnyCallable], classmethod]]:
|
||||
) -> Union[classmethod, Callable[[AnyCallable], classmethod]]: # type: ignore[type-arg]
|
||||
"""
|
||||
Decorate methods on a model indicating that they should be used to validate (and perhaps modify) data either
|
||||
before or after standard model parsing/validation is performed.
|
||||
@@ -122,7 +122,7 @@ def root_validator(
|
||||
)
|
||||
return f_cls
|
||||
|
||||
def dec(f: AnyCallable) -> classmethod:
|
||||
def dec(f: AnyCallable) -> classmethod: # type: ignore[type-arg]
|
||||
f_cls = _prepare_validator(f, allow_reuse)
|
||||
setattr(
|
||||
f_cls, ROOT_VALIDATOR_CONFIG_KEY, Validator(func=f_cls.__func__, pre=pre, skip_on_failure=skip_on_failure)
|
||||
@@ -132,7 +132,7 @@ def root_validator(
|
||||
return dec
|
||||
|
||||
|
||||
def _prepare_validator(function: AnyCallable, allow_reuse: bool) -> classmethod:
|
||||
def _prepare_validator(function: AnyCallable, allow_reuse: bool) -> classmethod: # type: ignore[type-arg]
|
||||
"""
|
||||
Avoid validators with duplicated names since without this, validators can be overwritten silently
|
||||
which generally isn't the intended behaviour, don't run in ipython (see #312) or if allow_reuse is False.
|
||||
@@ -325,7 +325,7 @@ def _generic_validator_basic(validator: AnyCallable, sig: 'Signature', args: Set
|
||||
return lambda cls, v, values, field, config: validator(v, values=values, field=field, config=config)
|
||||
|
||||
|
||||
def gather_all_validators(type_: 'ModelOrDc') -> Dict[str, classmethod]:
|
||||
def gather_all_validators(type_: 'ModelOrDc') -> Dict[str, classmethod]: # type: ignore[type-arg]
|
||||
all_attributes = ChainMap(*[cls.__dict__ for cls in type_.__mro__])
|
||||
return {
|
||||
k: v
|
||||
|
||||
+3
-3
@@ -890,7 +890,7 @@ def create_model(
|
||||
__config__: Optional[Type[BaseConfig]] = None,
|
||||
__base__: None = None,
|
||||
__module__: str = __name__,
|
||||
__validators__: Dict[str, classmethod] = None,
|
||||
__validators__: Dict[str, classmethod] = None, # type: ignore[type-arg]
|
||||
**field_definitions: Any,
|
||||
) -> Type['BaseModel']:
|
||||
...
|
||||
@@ -903,7 +903,7 @@ def create_model(
|
||||
__config__: Optional[Type[BaseConfig]] = None,
|
||||
__base__: Union[Type['Model'], Tuple[Type['Model'], ...]],
|
||||
__module__: str = __name__,
|
||||
__validators__: Dict[str, classmethod] = None,
|
||||
__validators__: Dict[str, classmethod] = None, # type: ignore[type-arg]
|
||||
**field_definitions: Any,
|
||||
) -> Type['Model']:
|
||||
...
|
||||
@@ -915,7 +915,7 @@ def create_model(
|
||||
__config__: Optional[Type[BaseConfig]] = None,
|
||||
__base__: Union[None, Type['Model'], Tuple[Type['Model'], ...]] = None,
|
||||
__module__: str = __name__,
|
||||
__validators__: Dict[str, classmethod] = None,
|
||||
__validators__: Dict[str, classmethod] = None, # type: ignore[type-arg]
|
||||
**field_definitions: Any,
|
||||
) -> Type['Model']:
|
||||
"""
|
||||
|
||||
+3
-3
@@ -348,13 +348,13 @@ class PydanticModelTransformer:
|
||||
and does not treat settings fields as optional.
|
||||
"""
|
||||
ctx = self._ctx
|
||||
set_str = ctx.api.named_type('__builtins__.set', [ctx.api.named_type('__builtins__.str')])
|
||||
set_str = ctx.api.named_type('builtins.set', [ctx.api.named_type('builtins.str')])
|
||||
optional_set_str = UnionType([set_str, NoneType()])
|
||||
fields_set_argument = Argument(Var('_fields_set', optional_set_str), optional_set_str, None, ARG_OPT)
|
||||
construct_arguments = self.get_field_arguments(fields, typed=True, force_all_optional=False, use_alias=False)
|
||||
construct_arguments = [fields_set_argument] + construct_arguments
|
||||
|
||||
obj_type = ctx.api.named_type('__builtins__.object')
|
||||
obj_type = ctx.api.named_type('builtins.object')
|
||||
self_tvar_name = '_PydanticBaseModel' # Make sure it does not conflict with other names in the class
|
||||
tvar_fullname = ctx.cls.fullname + '.' + self_tvar_name
|
||||
self_type = TypeVarType(self_tvar_name, tvar_fullname, -1, [], obj_type)
|
||||
@@ -654,7 +654,7 @@ def add_method(
|
||||
arg_names.append(get_name(arg.variable))
|
||||
arg_kinds.append(arg.kind)
|
||||
|
||||
function_type = ctx.api.named_type('__builtins__.function')
|
||||
function_type = ctx.api.named_type('builtins.function')
|
||||
signature = CallableType(arg_types, arg_kinds, arg_names, return_type, function_type)
|
||||
if tvar_like_type:
|
||||
signature.variables = [tvar_like_type]
|
||||
|
||||
+1
-1
@@ -574,7 +574,7 @@ class ValueItems(Representation):
|
||||
elif isinstance(items, AbstractSet):
|
||||
items = dict.fromkeys(items, ...)
|
||||
else:
|
||||
raise TypeError(f'Unexpected type of exclude value {items.__class__}')
|
||||
raise TypeError(f'Unexpected type of exclude value {items.__class__}') # type: ignore[attr-defined]
|
||||
return items
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
186: error: Unexpected keyword argument "z" for "AliasGeneratorModel2" [call-arg]
|
||||
189: error: Name "Missing" is not defined [name-defined]
|
||||
197: error: No overload variant of "dataclass" matches argument type "Dict[<nothing>, <nothing>]" [call-overload]
|
||||
197: note: Possible overload variant:
|
||||
197: note: Possible overload variants:
|
||||
197: note: def dataclass(*, init: bool = ..., repr: bool = ..., eq: bool = ..., order: bool = ..., unsafe_hash: bool = ..., frozen: bool = ..., config: Optional[Type[Any]] = ...) -> Callable[[Type[Any]], Type[Dataclass]]
|
||||
197: note: <1 more non-matching overload not shown>
|
||||
197: note: def dataclass(_cls: Type[Any], *, init: bool = ..., repr: bool = ..., eq: bool = ..., order: bool = ..., unsafe_hash: bool = ..., frozen: bool = ..., config: Optional[Type[Any]] = ...) -> Type[Dataclass]
|
||||
219: error: Property "y" defined in "FrozenModel" is read-only [misc]
|
||||
@@ -18,11 +18,11 @@
|
||||
101: error: Missing named argument "y" for "construct" of "Model" [call-arg]
|
||||
103: error: Argument "x" to "construct" of "Model" has incompatible type "str"; expected "int" [arg-type]
|
||||
156: error: Missing named argument "x" for "DynamicAliasModel2" [call-arg]
|
||||
175: error: unused "type: ignore" comment
|
||||
182: error: unused "type: ignore" comment
|
||||
175: error: Unused "type: ignore" comment
|
||||
182: error: Unused "type: ignore" comment
|
||||
189: error: Name "Missing" is not defined [name-defined]
|
||||
197: error: No overload variant of "dataclass" matches argument type "Dict[<nothing>, <nothing>]" [call-overload]
|
||||
197: note: Possible overload variant:
|
||||
197: note: Possible overload variants:
|
||||
197: note: def dataclass(*, init: bool = ..., repr: bool = ..., eq: bool = ..., order: bool = ..., unsafe_hash: bool = ..., frozen: bool = ..., config: Optional[Type[Any]] = ...) -> Callable[[Type[Any]], Type[Dataclass]]
|
||||
197: note: <1 more non-matching overload not shown>
|
||||
197: note: def dataclass(_cls: Type[Any], *, init: bool = ..., repr: bool = ..., eq: bool = ..., order: bool = ..., unsafe_hash: bool = ..., frozen: bool = ..., config: Optional[Type[Any]] = ...) -> Type[Dataclass]
|
||||
219: error: Property "y" defined in "FrozenModel" is read-only [misc]
|
||||
@@ -3,7 +3,7 @@ flake8==4.0.1
|
||||
flake8-quotes==3.3.1
|
||||
hypothesis==6.31.6
|
||||
isort==5.10.1
|
||||
mypy==0.920
|
||||
mypy==0.930
|
||||
pre-commit==2.16.0
|
||||
pycodestyle==2.8.0
|
||||
pyflakes==2.4.0
|
||||
|
||||
@@ -2,7 +2,7 @@ coverage==6.2
|
||||
hypothesis==6.31.6
|
||||
# pin importlib-metadata as upper versions need typing-extensions to work if on python < 3.8
|
||||
importlib-metadata==3.1.0;python_version<"3.8"
|
||||
mypy==0.920
|
||||
mypy==0.930
|
||||
pytest==6.2.5
|
||||
pytest-cov==3.0.0
|
||||
pytest-mock==3.6.1
|
||||
|
||||
Reference in New Issue
Block a user