-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
ruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Summary
The folks at Pydantic somewhat recently added an alternate migration path which allows you to use v1 from v2.
Ruff does not correctly identify this case as a valid exception to RUF012
Example:
from pydantic.v1.main import BaseModel
class Foo(BaseModel):
bar: list[str] = ['baz'] # <- triggers RUF012Fix:
from pydantic.v1 import BaseModel # removing the .main here works
class Foo(BaseModel):
bar: list[str] = ['baz'] # <- triggers RUF012Perhaps it would be a good idea to add a setting to mark exceptions to this rule...
Or maybe there's another rule I should activate to force the simpler import since pyright is still really bad at prioritizing the right import paths (often suggesting indirect imports through third party libraries or subpackages even when stuff is exposed from the top level module of a library)
Version
No response
Metadata
Metadata
Assignees
Labels
ruleImplementing or modifying a lint ruleImplementing or modifying a lint rule