Skip to content

Commit

Permalink
Replace TypeVarDef with TypeVarType
Browse files Browse the repository at this point in the history
Problem: While using the Pydantic plugin with bleeding-edge Mypy I
realized that Pydantic is using a recently-removed type.

Solution: Find two instances of `TypeVarDef` and rename to
`TypeVarType`.

See-also: python/mypy#9951
  • Loading branch information
christianbundy committed Sep 5, 2021
1 parent 63e42db commit 2b1818b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pydantic/mypy.py
Expand Up @@ -57,7 +57,6 @@
Type,
TypeOfAny,
TypeType,
TypeVarDef,
TypeVarType,
UnionType,
get_proper_type,
Expand Down Expand Up @@ -352,7 +351,7 @@ def add_construct_method(self, fields: List['PydanticModelField']) -> None:
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)
tvd = 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)
self_type = TypeVarType(tvd)
Expand Down Expand Up @@ -614,7 +613,7 @@ def add_method(
args: List[Argument],
return_type: Type,
self_type: Optional[Type] = None,
tvar_def: Optional[TypeVarDef] = None,
tvar_def: Optional[TypeVarType] = None,
is_classmethod: bool = False,
is_new: bool = False,
# is_staticmethod: bool = False,
Expand Down

0 comments on commit 2b1818b

Please sign in to comment.