Fix mypy plugin issue with self field (#2743)

* Fix mypy issue with self field

* Add docs
This commit is contained in:
Yurii Karabas
2021-09-04 05:15:49 +03:00
committed by GitHub
parent 8c6b9ca285
commit 0d1ed534ac
3 changed files with 6 additions and 1 deletions
+1
View File
@@ -0,0 +1 @@
Fix mypy plugin issue with self field declaration.
+1 -1
View File
@@ -619,7 +619,7 @@ def add_method(
# first = []
else:
self_type = self_type or fill_typevars(info)
first = [Argument(Var('self'), self_type, None, ARG_POS)]
first = [Argument(Var('__pydantic_self__'), self_type, None, ARG_POS)]
args = first + args
arg_types, arg_names, arg_kinds = [], [], []
for arg in args:
+4
View File
@@ -158,3 +158,7 @@ class NotFrozenModel(FrozenModel):
NotFrozenModel(x=1).x = 2
NotFrozenModel.from_orm(model)
class ModelWithSelfField(BaseModel):
self: str