Skip to content

Commit 3820af2

Browse files
[pycodestyle] Avoid false positives related to type aliases (E252) (#15356)
1 parent ee9a912 commit 3820af2

File tree

2 files changed

+13
-1
lines changed
  • crates/ruff_linter
    • resources/test/fixtures/pycodestyle
    • src/rules/pycodestyle/rules/logical_lines

2 files changed

+13
-1
lines changed

crates/ruff_linter/resources/test/fixtures/pycodestyle/E25.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,15 @@ def pep_696_good_method[A = int, B: object = str, C:object = memoryview](self):
7979

8080
# https://github.com/astral-sh/ruff/issues/15202
8181
type Coro[T: object = Any] = Coroutine[None, None, T]
82+
83+
84+
# https://github.com/astral-sh/ruff/issues/15339
85+
type A = Annotated[
86+
str, Foo(lorem='ipsum')
87+
]
88+
type B = Annotated[
89+
int, lambda a=1: ...
90+
]
91+
type C = Annotated[
92+
int, lambda a: ..., lambda a=1: ...
93+
]

crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ impl DefinitionState {
531531
Self::NotInDefinition => return,
532532
};
533533
match token_kind {
534-
TokenKind::Lpar if type_params_state_mut.before_type_params() => {
534+
TokenKind::Lpar | TokenKind::Equal if type_params_state_mut.before_type_params() => {
535535
*type_params_state_mut = TypeParamsState::TypeParamsEnded;
536536
}
537537
TokenKind::Lsqb => match type_params_state_mut {

0 commit comments

Comments
 (0)