Describe the bug
Inheriting a metaclass decorated with @dataclass_transform is not properly inherited.
A workaround is to duplicate the @dataclass_transform decorator on the new metaclass.
To Reproduce
Create a new class and inherit a dataclass base meta with @dataclass_transform. Use that class as the metaclass for a new class inheriting from your dataclass base and give it some annotated attributes.
The type of the newly created class is class Foo(*args: Any, **kwargs: Any). Any arguments given to it will result in No parameter named "x"
Expected behavior
The expected type of the class should include its fields. class TypeName(*, x: str)
Code or Screenshots
from typing import dataclass_transform
@dataclass_transform(kw_only_default=True)
class ModelMeta(type):
pass
class BaseModel(metaclass=ModelMeta):
pass
class MyModel(BaseModel):
x: str
MyModel(x="fff") # ok
class BetterModelMeta(ModelMeta):
pass
class BetterModel(BaseModel, metaclass=BetterModelMeta):
x: str
BetterModel(x="dfdd") # No parameter named "x"
VS Code extension or command-line
Pyright CLI 1.1.316