[ruff] - fix false positive for decorators (RUF028) (#14061)

This commit is contained in:
Steve C 2024-11-03 06:49:03 -05:00 committed by GitHub
parent f69712c11d
commit ae9f08d1e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View file

@ -87,3 +87,17 @@ def match_case_and_elif():
pass
elif string == "Hello": # fmt: skip
pass
# Regression test for decorators
import pytest
@pytest.mark.parametrize(
"test_input,expected",
[
("3+5", 8 ),
("17+2", 19),
],
) # fmt: skip
def test_eval(test_input, expected):
assert eval(test_input) == expected

View file

@ -278,6 +278,7 @@ const fn is_valid_enclosing_node(node: AnyNodeRef) -> bool {
| AnyNodeRef::StmtIpyEscapeCommand(_)
| AnyNodeRef::ExceptHandlerExceptHandler(_)
| AnyNodeRef::MatchCase(_)
| AnyNodeRef::Decorator(_)
| AnyNodeRef::ElifElseClause(_) => true,
AnyNodeRef::ExprBoolOp(_)
@ -333,7 +334,6 @@ const fn is_valid_enclosing_node(node: AnyNodeRef) -> bool {
| AnyNodeRef::Keyword(_)
| AnyNodeRef::Alias(_)
| AnyNodeRef::WithItem(_)
| AnyNodeRef::Decorator(_)
| AnyNodeRef::TypeParams(_)
| AnyNodeRef::TypeParamTypeVar(_)
| AnyNodeRef::TypeParamTypeVarTuple(_)