Skip to content

@final and @override diagnostics are not emitted if there are multiple reachable definitions #1677

@AlexWaygood

Description

@AlexWaygood

Summary

Consider this snippet:

from typing import final, override

def coinflip() -> bool:
    return False

class A:
    @final
    def method(self) -> None: ...

    if coinflip():
        @override
        def wut(self) -> None: ...
    else:
        @override
        def wut(self) -> None: ...

class B(A):
    if coinflip():
        def method(self) -> None: ...
    else:
        def method(self) -> None: ...

We should emit diagnostics on the definitions of A.wut and B.method, but we currently do not:

  • A.wut is marked with @override but doesn't override anything
  • B.method overrides a method decorated with @final

Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions