mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 04:19:43 +00:00
[ruff
] - fix false positive for decorators (RUF028
) (#14061)
This commit is contained in:
parent
f69712c11d
commit
ae9f08d1e5
2 changed files with 15 additions and 1 deletions
|
@ -87,3 +87,17 @@ def match_case_and_elif():
|
||||||
pass
|
pass
|
||||||
elif string == "Hello": # fmt: skip
|
elif string == "Hello": # fmt: skip
|
||||||
pass
|
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
|
||||||
|
|
|
@ -278,6 +278,7 @@ const fn is_valid_enclosing_node(node: AnyNodeRef) -> bool {
|
||||||
| AnyNodeRef::StmtIpyEscapeCommand(_)
|
| AnyNodeRef::StmtIpyEscapeCommand(_)
|
||||||
| AnyNodeRef::ExceptHandlerExceptHandler(_)
|
| AnyNodeRef::ExceptHandlerExceptHandler(_)
|
||||||
| AnyNodeRef::MatchCase(_)
|
| AnyNodeRef::MatchCase(_)
|
||||||
|
| AnyNodeRef::Decorator(_)
|
||||||
| AnyNodeRef::ElifElseClause(_) => true,
|
| AnyNodeRef::ElifElseClause(_) => true,
|
||||||
|
|
||||||
AnyNodeRef::ExprBoolOp(_)
|
AnyNodeRef::ExprBoolOp(_)
|
||||||
|
@ -333,7 +334,6 @@ const fn is_valid_enclosing_node(node: AnyNodeRef) -> bool {
|
||||||
| AnyNodeRef::Keyword(_)
|
| AnyNodeRef::Keyword(_)
|
||||||
| AnyNodeRef::Alias(_)
|
| AnyNodeRef::Alias(_)
|
||||||
| AnyNodeRef::WithItem(_)
|
| AnyNodeRef::WithItem(_)
|
||||||
| AnyNodeRef::Decorator(_)
|
|
||||||
| AnyNodeRef::TypeParams(_)
|
| AnyNodeRef::TypeParams(_)
|
||||||
| AnyNodeRef::TypeParamTypeVar(_)
|
| AnyNodeRef::TypeParamTypeVar(_)
|
||||||
| AnyNodeRef::TypeParamTypeVarTuple(_)
|
| AnyNodeRef::TypeParamTypeVarTuple(_)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue