mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
@@ -0,0 +1 @@
|
||||
Fix false positive from mypy plugin when a class nested within a `BaseModel` is named `Model`.
|
||||
+1
-1
@@ -328,7 +328,7 @@ class PydanticModelTransformer:
|
||||
construct_arguments = [fields_set_argument] + construct_arguments
|
||||
|
||||
obj_type = ctx.api.named_type('__builtins__.object')
|
||||
self_tvar_name = 'Model'
|
||||
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_tvar_expr = TypeVarExpr(self_tvar_name, tvar_fullname, [], obj_type)
|
||||
|
||||
@@ -123,3 +123,13 @@ p = AddProject(name='x', slug='y', description='z')
|
||||
|
||||
class TypeAliasAsAttribute(BaseModel):
|
||||
__type_alias_attribute__ = Union[str, bytes]
|
||||
|
||||
|
||||
class NestedModel(BaseModel):
|
||||
class Model(BaseModel):
|
||||
id: str
|
||||
|
||||
model: Model
|
||||
|
||||
|
||||
_ = NestedModel.Model
|
||||
|
||||
Reference in New Issue
Block a user