Open DetachHead opened 1 day ago
another issue with reportUnsafeMultipleInheritance
:
from abc import ABC
from pydantic import BaseModel
class Foo:
def __init__(self) -> None:
pass
class Bar(Foo, BaseModel): ... # error: reportUnsafeMultipleInheritance
this is because BaseModel
uses dataclass_transform
which assumes Bar
now acts like a dataclass, but the generated __init__
methods in dataclasses don't call super().__init__
. this is not the case with pydantic models so this situation is safe
there are many limitations with pyright's approach to pydantic, which is trying to get all its features to be standardized in the type system in the most special-cased way imaginable. creating the
dataclass_transform
decorator may have been easier than creating type system features to support the underlying runtime functionality that pydantic relies on, but what's the point of doing that instead of just making a plugin when the standardized features are so obviously specifically designed just for pydantic anyway.once we have a plugin system (#22) we should just fix these issues using that instead:
667