Avoid N802 violations for @overload methods (#7498)

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
This commit is contained in:
Jonathan Plasse 2023-09-18 20:32:40 +02:00 committed by GitHub
parent 359f50e6dc
commit 2421805033
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -41,9 +41,13 @@ class Test(unittest.TestCase):
assert True
from typing import override
from typing import override, overload
@override
def BAD_FUNC():
pass
@overload
def BAD_FUNC():
pass

View File

@ -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;
}