◐ Shell
clean mode source ↗

Conformance: test that `@override` checks are honored for `__init__` / `__new__`

When explicitly marking a method with @override, type checkers ought to test assignability (https://typing.python.org/en/latest/spec/class-compat.html#override).

Hence, even methods like __init__ and __new__, which are normally not checked against their parent classes, should be checked when explicilty decorated with @override.

from typing import override

class Foo:
    def __init__(self, x: int) -> None: ...

class Bar(Foo):
    @override
    def __init__(self, y: int) -> None: ...  # should error

This is useful in cases when we really need constructors to be compatible.
I suggest adding a version of the example above to the conformance test suite.