[pycodestyle] Avoid false positives related to type aliases (E252) (#15356)

This commit is contained in:
InSync 2025-01-08 22:04:08 +07:00 committed by GitHub
parent ee9a912f47
commit 3820af2f1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View file

@ -79,3 +79,15 @@ class PEP696Good[A = int, B: object = str, C:object = memoryview]:
# https://github.com/astral-sh/ruff/issues/15202
type Coro[T: object = Any] = Coroutine[None, None, T]
# https://github.com/astral-sh/ruff/issues/15339
type A = Annotated[
str, Foo(lorem='ipsum')
]
type B = Annotated[
int, lambda a=1: ...
]
type C = Annotated[
int, lambda a: ..., lambda a=1: ...
]

View file

@ -531,7 +531,7 @@ impl DefinitionState {
Self::NotInDefinition => return,
};
match token_kind {
TokenKind::Lpar if type_params_state_mut.before_type_params() => {
TokenKind::Lpar | TokenKind::Equal if type_params_state_mut.before_type_params() => {
*type_params_state_mut = TypeParamsState::TypeParamsEnded;
}
TokenKind::Lsqb => match type_params_state_mut {