-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Attribute cannot have the same name as its type #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is a consequence of how python annotations work and not specific to pydantic:
I've no idea if this is intentional behaviour or a bug in the standard library but there's nothing pydantic can do about it since it's just consulting the |
This is related to python/mypy#1775 so using your example before class A(BaseModel):
pass
class B(BaseModel):
A: A = None after class A(BaseModel):
pass
_A = A
class B(BaseModel):
A: _A = None |
alexdrydew
pushed a commit
to alexdrydew/pydantic
that referenced
this issue
Dec 23, 2023
* check items() exists before calling it a mapping * linting
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am trying to make the class attribute having the same name as its type. The following code does not work and show the
ConfigError
However, if I make the attribute no default value then it works
Is this behavior intended?
The text was updated successfully, but these errors were encountered: