Skip to content

Commit

Permalink
Avoid N802 violations for @overload methods (#7498)
Browse files Browse the repository at this point in the history
Close #7479

The `@override` was already implemented

## Test Plan

Tested the code in the issue. After removing all the noqa's, only one
occurrence of `BadName()` raised a violation.
Added a fixture
  • Loading branch information
JonathanPlasse authored Sep 18, 2023
1 parent 359f50e commit 2421805
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion crates/ruff/resources/test/fixtures/pep8_naming/N802.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ def testTest(self):
assert True


from typing import override
from typing import override, overload


@override
def BAD_FUNC():
pass

@overload
def BAD_FUNC():
pass
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ pub(crate) fn invalid_function_name(
return None;
}

// Ignore any functions that are explicitly `@override`. These are defined elsewhere,
// so if they're first-party, we'll flag them at the definition site.
if visibility::is_override(decorator_list, semantic) {
// Ignore any functions that are explicitly `@override` or `@overload`.
// These are defined elsewhere, so if they're first-party,
// we'll flag them at the definition site.
if visibility::is_override(decorator_list, semantic)
|| visibility::is_overload(decorator_list, semantic)
{
return None;
}

Expand Down

0 comments on commit 2421805

Please sign in to comment.