We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
RUF012 normally ignores pydantic models but not when the class inherits from an imported model. Eg: file b.py
from pydantic import BaseModel class B(BaseModel): pass
file a.py
from pydantic import BaseModel from b import B class Foo(B): foo: list[str] = [] class C(BaseModel): pass class Bar(C): bar: list[str] = []
Then run ruff
ruff check --select RUF012 a.py:5:22: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` | 4 | class Foo(B): 5 | foo: list[str] = [] | ^^ RUF012 6 | 7 | class C(BaseModel): | Found 1 error.
I would expect ruff to not error.
The text was updated successfully, but these errors were encountered:
Ruff doesn't support multi-file analysis yet, we can't inspect the type across the import boundary
xref #7447
Sorry, something went wrong.
Thanks for the info. I'll follow #7447 with interest then.
We're actively working on it, but it's a ways out.
No branches or pull requests
RUF012 normally ignores pydantic models but not when the class inherits from an imported model.
Eg: file b.py
file a.py
Then run ruff
I would expect ruff to not error.
The text was updated successfully, but these errors were encountered: