mirror of https://github.com/astral-sh/ruff
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:
parent
359f50e6dc
commit
2421805033
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue