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
|
assert True
|
||||||
|
|
||||||
|
|
||||||
from typing import override
|
from typing import override, overload
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
def BAD_FUNC():
|
def BAD_FUNC():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def BAD_FUNC():
|
||||||
|
pass
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,12 @@ pub(crate) fn invalid_function_name(
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore any functions that are explicitly `@override`. These are defined elsewhere,
|
// Ignore any functions that are explicitly `@override` or `@overload`.
|
||||||
// so if they're first-party, we'll flag them at the definition site.
|
// These are defined elsewhere, so if they're first-party,
|
||||||
if visibility::is_override(decorator_list, semantic) {
|
// we'll flag them at the definition site.
|
||||||
|
if visibility::is_override(decorator_list, semantic)
|
||||||
|
|| visibility::is_overload(decorator_list, semantic)
|
||||||
|
{
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue