DetachHead / basedpyright

pyright fork with various type checking improvements, improved vscode support and pylance features built into the language server
https://docs.basedpyright.com
Other
1.18k stars 21 forks source link

`reportUnsafeMultipleInheritance` false positive on class when an `__init__` method is present in instance of the metaclass that uses `dataclass_transform` #869

Closed DetachHead closed 1 day ago

DetachHead commented 1 day ago

Code sample in basedpyright playground

from typing import dataclass_transform

@dataclass_transform()
class A(type): ...

class Foo(metaclass=A):
    def __init__(self) -> None:
        print("called")

class B: ...

class Bar(Foo, B): ...  # error: reportUnsafeMultipleInheritance

print(Bar())  # prints "called"

if the __init__ was in B instead of Foo, the error would be correct. see https://github.com/DetachHead/basedpyright/issues/868#issuecomment-2472205770

DetachHead commented 1 day ago

actually this is just the same issue as https://github.com/DetachHead/basedpyright/issues/868#issuecomment-2472205770, since Foo is treated as a dataclass as well