Skip to content

Conformance tests: classes_override.py should allow highlighting the decorator #1955

@alvov26

Description

@alvov26

While working on support for this test in PyCharm, I noticed that it requires highlighting the function signature instead of the decorator (which is how PyCharm currently handles it).
For example:

    @staticmethod
    @override
    def static_method1() -> int:  # E: no matching signature in ancestor
        return 1

    @classmethod
    @override
    def class_method1(cls) -> int:  # E: no matching signature in ancestor
        return 1

This would be easy to change on our end, but I believe allowing the option to highlight the decorator would be preferable for several reasons:

  1. Highlighting the function signature may overlap with other checks, such as PyCharm inspections or other linters.
  2. If the decorator is removed, the error no longer applies, so highlighting the decorator itself makes sense.
  3. Other conformance tests already allow highlighting decorators. For example:
  • qualifiers_final_decorator.py
@final  # E[func]: not allowed on non-method function.
def func1() -> int:  # E[func]
    return 0
  • overloads_definitions.py
@overload  # E[func2]
def func2(x: int) -> int:  # E[func2]: no implementation
    ...

If this change makes sense, I’d be happy to submit a PR to update the test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: otherOther topics not covered

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions