mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 06:11:43 +00:00

## Summary Follow-up to #16026. Previously, the fix for this would be marked as unsafe, even though all comments are preserved: ```python # .pyi T: TypeAlias = ( # Comment int | str ) ``` Now it is safe: comments within the parenthesized range no longer affect applicability. ## Test Plan `cargo nextest run` and `cargo insta test`. --------- Co-authored-by: Dylan <53534755+dylwil3@users.noreply.github.com>
24 lines
463 B
Python
24 lines
463 B
Python
import typing
|
|
from typing import TypeAlias
|
|
|
|
# UP040
|
|
# Fixes in type stub files should be safe to apply unlike in regular code where runtime behavior could change
|
|
x: typing.TypeAlias = int
|
|
x: TypeAlias = int
|
|
|
|
|
|
# comments in the value are preserved
|
|
x: TypeAlias = tuple[
|
|
int, # preserved
|
|
float,
|
|
]
|
|
|
|
T: TypeAlias = ( # comment0
|
|
# comment1
|
|
int # comment2
|
|
# comment3
|
|
| # comment4
|
|
# comment5
|
|
str # comment6
|
|
# comment7
|
|
) # comment8
|