Skip to content

Commit 2b1818b

Browse files
Replace TypeVarDef with TypeVarType
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
1 parent 63e42db commit 2b1818b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pydantic/mypy.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
Type,
5858
TypeOfAny,
5959
TypeType,
60-
TypeVarDef,
6160
TypeVarType,
6261
UnionType,
6362
get_proper_type,
@@ -352,7 +351,7 @@ def add_construct_method(self, fields: List['PydanticModelField']) -> None:
352351
obj_type = ctx.api.named_type('__builtins__.object')
353352
self_tvar_name = '_PydanticBaseModel' # Make sure it does not conflict with other names in the class
354353
tvar_fullname = ctx.cls.fullname + '.' + self_tvar_name
355-
tvd = TypeVarDef(self_tvar_name, tvar_fullname, -1, [], obj_type)
354+
tvd = TypeVarType(self_tvar_name, tvar_fullname, -1, [], obj_type)
356355
self_tvar_expr = TypeVarExpr(self_tvar_name, tvar_fullname, [], obj_type)
357356
ctx.cls.info.names[self_tvar_name] = SymbolTableNode(MDEF, self_tvar_expr)
358357
self_type = TypeVarType(tvd)
@@ -614,7 +613,7 @@ def add_method(
614613
args: List[Argument],
615614
return_type: Type,
616615
self_type: Optional[Type] = None,
617-
tvar_def: Optional[TypeVarDef] = None,
616+
tvar_def: Optional[TypeVarType] = None,
618617
is_classmethod: bool = False,
619618
is_new: bool = False,
620619
# is_staticmethod: bool = False,

0 commit comments

Comments
 (0)