Skip to content

Commit

Permalink
[ruff] - fix false positive for decorators (RUF028) (#14061)
Browse files Browse the repository at this point in the history
  • Loading branch information
diceroll123 authored Nov 3, 2024
1 parent f69712c commit ae9f08d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/ruff/RUF028.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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(_)
Expand Down Expand Up @@ -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(_)
Expand Down

0 comments on commit ae9f08d

Please sign in to comment.