Skip to content
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

No missing attribute error by mypy #95

Closed
yamitzky opened this issue Nov 1, 2017 · 2 comments
Closed

No missing attribute error by mypy #95

yamitzky opened this issue Nov 1, 2017 · 2 comments

Comments

@yamitzky
Copy link

yamitzky commented Nov 1, 2017

mypy does not warn missing attribute when inheriting BaseModel.

from pydantic import BaseModel

class A:
    x: int

class B(BaseModel):
    x: int

A().y
B(x=1).y
main.py:9: error: "A" has no attribute "y"

Can I check missing attribute for B().y?

@samuelcolvin
Copy link
Member

Thanks for the question.

I would guess this is because BaseModel implements __getattr__ so mypy can't easily work out whether B().y would raise an AttributeError.

Not really much we can do about this I'm afraid.

@yamitzky
Copy link
Author

yamitzky commented Nov 2, 2017

I see... Thanks for your reply!

alexdrydew pushed a commit to alexdrydew/pydantic that referenced this issue Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants