Skip to content

Commit a7f95cd

Browse files
committed
Fix detection of Pydantic models in ASTStubGenerator
1 parent 7012189 commit a7f95cd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

mypy/stubgen.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -863,9 +863,10 @@ def visit_class_def(self, o: ClassDef) -> None:
863863
self.dataclass_field_specifier = spec.field_specifiers
864864
is_pydantic_model = False
865865
for base_type_expr in o.base_type_exprs:
866-
if isinstance(base_type_expr, (NameExpr, MemberExpr)) and self.get_fullname(
867-
base_type_expr
868-
).endswith("pydantic.BaseModel"):
866+
if (
867+
isinstance(base_type_expr, (NameExpr, MemberExpr))
868+
and self.get_fullname(base_type_expr) == "pydantic.BaseModel"
869+
):
869870
is_pydantic_model = True
870871
break
871872
self.processing_pydantic_model = is_pydantic_model

0 commit comments

Comments
 (0)