Skip to content

False-positive N803 with overrides #15925

@bersbersbers

Description

@bersbersbers

Description

This is my code. BadClass is bad, but I have to live with it:

from typing import override


class BadClass:
    def fun(self, DaTa: int) -> None: ...  # noqa: N803


class MyClass(BadClass):
    @override
    def fun(self, DaTa: int) -> None: ...

ruff --isolated check --select=N803 bug.py (v0.9.4) gives:

>ruff --isolated check --select=N803 bug.py
bug.py:10:19: N803 Argument name `DaTa` should be lowercase
   |
 8 | class MyClass(BadClass):
 9 |     @override
10 |     def fun(self, DaTa: int) -> None: ...
   |                   ^^^^^^^^^ N803
   |

However, I'd argue I have to name that argument that way - otherwise, pyright tells me:

c:\Git\project\bug.py
  c:\Git\project\bug.py:10:9 - error: Method "fun" overrides class "BadClass" in an incompatible manner
    Parameter 2 name mismatch: base parameter is named "DaTa", override parameter is named "data" (reportIncompatibleMethodOverride)
1 error, 0 warnings, 0 informations

So I'd argue that N803 should ignore functions with @override (as well as their @overloads!).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedContributions especially welcomeruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions