build(deps): bump mypy from 0.910 to 0.920 (#3552)

* build(deps): bump mypy from 0.910 to 0.920

Bumps [mypy](https://github.com/python/mypy) from 0.910 to 0.920.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](https://github.com/python/mypy/compare/v0.910...v0.920)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix mypy issues

* fix mypy issues

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: PrettyWood <em.jolibois@gmail.com>
This commit is contained in:
dependabot[bot]
2021-12-24 13:11:05 +00:00
committed by GitHub
parent 5ce652bf84
commit e14e7561ed
9 changed files with 20 additions and 31 deletions
+2 -3
View File
@@ -169,9 +169,8 @@ def _process_class(
if field.default is not dataclasses.MISSING:
default = field.default
# mypy issue 7020 and 708
elif field.default_factory is not dataclasses.MISSING: # type: ignore
default_factory = field.default_factory # type: ignore
elif field.default_factory is not dataclasses.MISSING:
default_factory = field.default_factory
else:
default = Required
+1 -1
View File
@@ -245,4 +245,4 @@ def parse_duration(value: StrBytesIntFloat) -> timedelta:
kw_ = {k: float(v) for k, v in kw.items() if v is not None}
return sign * timedelta(**kw_) # type: ignore
return sign * timedelta(**kw_)
+1
View File
@@ -258,6 +258,7 @@ def replace_types(type_: Any, type_map: Mapping[Any, Any]) -> Any:
# `type` or `collections.abc.Callable` need to be translated.
# See: https://www.python.org/dev/peps/pep-0585
origin_type = getattr(typing, type_._name)
assert origin_type is not None
return origin_type[resolved_type_args]
# We handle pydantic generic models separately as they don't have the same
+6 -18
View File
@@ -15,13 +15,6 @@ except ImportError: # pragma: no cover
warnings.warn('No TOML parser installed, cannot read configuration from `pyproject.toml`.')
toml = None # type: ignore
try:
from mypy.types import TypeVarDef
except ImportError: # pragma: no cover
# Backward-compatible with TypeVarDef from Mypy 0.910.
from mypy.types import TypeVarType as TypeVarDef # type: ignore[misc]
from mypy.errorcodes import ErrorCode
from mypy.nodes import (
ARG_NAMED,
@@ -67,6 +60,7 @@ from mypy.types import (
Type,
TypeOfAny,
TypeType,
TypeVarLikeType,
TypeVarType,
UnionType,
get_proper_type,
@@ -363,23 +357,17 @@ class PydanticModelTransformer:
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
tvd = TypeVarDef(self_tvar_name, tvar_fullname, -1, [], obj_type)
self_type = TypeVarType(self_tvar_name, tvar_fullname, -1, [], obj_type)
self_tvar_expr = TypeVarExpr(self_tvar_name, tvar_fullname, [], obj_type)
ctx.cls.info.names[self_tvar_name] = SymbolTableNode(MDEF, self_tvar_expr)
# Backward-compatible with TypeVarDef from Mypy 0.910.
if isinstance(tvd, TypeVarType): # pragma: no cover
self_type = tvd
else:
self_type = TypeVarType(tvd)
add_method(
ctx,
'construct',
construct_arguments,
return_type=self_type,
self_type=self_type,
tvar_def=tvd,
tvar_like_type=self_type,
is_classmethod=True,
)
@@ -631,7 +619,7 @@ def add_method(
args: List[Argument],
return_type: Type,
self_type: Optional[Type] = None,
tvar_def: Optional[TypeVarDef] = None,
tvar_like_type: Optional[TypeVarLikeType] = None,
is_classmethod: bool = False,
is_new: bool = False,
# is_staticmethod: bool = False,
@@ -668,8 +656,8 @@ def add_method(
function_type = ctx.api.named_type('__builtins__.function')
signature = CallableType(arg_types, arg_kinds, arg_names, return_type, function_type)
if tvar_def:
signature.variables = [tvar_def]
if tvar_like_type:
signature.variables = [tvar_like_type]
func = FuncDef(name, args, Block([PassStmt()]))
func.info = info
+1
View File
@@ -285,6 +285,7 @@ class AnyUrl(str):
tld = d.group('tld')
if tld is None and not is_international:
d = int_domain_regex().fullmatch(host)
assert d is not None
tld = d.group('tld')
is_international = True
+3 -3
View File
@@ -110,7 +110,7 @@ if sys.version_info < (3, 8):
else:
from typing import get_origin as _typing_get_origin
def get_origin(tp: Type[Any]) -> Type[Any]:
def get_origin(tp: Type[Any]) -> Optional[Type[Any]]:
"""
We can't directly use `typing.get_origin` since we need a fallback to support
custom generic classes like `ConstrainedList`
@@ -188,7 +188,7 @@ else:
if sys.version_info < (3, 10):
def is_union(tp: Type[Any]) -> bool:
def is_union(tp: Optional[Type[Any]]) -> bool:
return tp is Union
WithArgsTypes = (TypingGenericAlias,)
@@ -197,7 +197,7 @@ else:
import types
import typing
def is_union(tp: Type[Any]) -> bool:
def is_union(tp: Optional[Type[Any]]) -> bool:
return tp is Union or tp is types.UnionType # noqa: E721
WithArgsTypes = (typing._GenericAlias, types.GenericAlias, types.UnionType)
+4 -4
View File
@@ -164,16 +164,16 @@ def validate_field_name(bases: List[Type['BaseModel']], field_name: str) -> None
)
def lenient_isinstance(o: Any, class_or_tuple: Union[Type[Any], Tuple[Type[Any], ...]]) -> bool:
def lenient_isinstance(o: Any, class_or_tuple: Union[Type[Any], Tuple[Type[Any], ...], None]) -> bool:
try:
return isinstance(o, class_or_tuple)
return isinstance(o, class_or_tuple) # type: ignore[arg-type]
except TypeError:
return False
def lenient_issubclass(cls: Any, class_or_tuple: Union[Type[Any], Tuple[Type[Any], ...]]) -> bool:
def lenient_issubclass(cls: Any, class_or_tuple: Union[Type[Any], Tuple[Type[Any], ...], None]) -> bool:
try:
return isinstance(cls, type) and issubclass(cls, class_or_tuple)
return isinstance(cls, type) and issubclass(cls, class_or_tuple) # type: ignore[arg-type]
except TypeError:
if isinstance(cls, WithArgsTypes):
return False
+1 -1
View File
@@ -3,7 +3,7 @@ flake8==4.0.1
flake8-quotes==3.3.1
hypothesis==6.31.6
isort==5.10.1
mypy==0.910
mypy==0.920
pre-commit==2.16.0
pycodestyle==2.8.0
pyflakes==2.4.0
+1 -1
View File
@@ -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.910
mypy==0.920
pytest==6.2.5
pytest-cov==3.0.0
pytest-mock==3.6.1