mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 10:22:24 +00:00
Introduce a new CST element for slice segments (#3195)
This commit is contained in:
parent
eb15371453
commit
6eaacf96be
8 changed files with 425 additions and 143 deletions
|
@ -29,3 +29,35 @@ ham[lower:upper], ham[lower:upper:], ham[lower::step]
|
|||
# ham[lower+offset : upper+offset]
|
||||
ham[: upper_fn(x) : step_fn(x)], ham[:: step_fn(x)]
|
||||
ham[lower + offset : upper + offset]
|
||||
|
||||
slice[::, ::]
|
||||
slice[
|
||||
# A
|
||||
:
|
||||
# B
|
||||
:
|
||||
# C
|
||||
]
|
||||
slice[
|
||||
# A
|
||||
1:
|
||||
# B
|
||||
2:
|
||||
# C
|
||||
3
|
||||
]
|
||||
|
||||
slice[
|
||||
# A
|
||||
1
|
||||
+ 2 :
|
||||
# B
|
||||
3 :
|
||||
# C
|
||||
4
|
||||
]
|
||||
x[
|
||||
1: # A
|
||||
2: # B
|
||||
3 # C
|
||||
]
|
||||
|
|
|
@ -29,3 +29,31 @@ ham[lower:upper], ham[lower:upper:], ham[lower::step]
|
|||
# ham[lower+offset : upper+offset]
|
||||
ham[: upper_fn(x) : step_fn(x)], ham[:: step_fn(x)]
|
||||
ham[lower + offset : upper + offset]
|
||||
|
||||
slice[::, ::]
|
||||
slice[
|
||||
# A
|
||||
:
|
||||
# B
|
||||
:
|
||||
# C
|
||||
]
|
||||
slice[
|
||||
# A
|
||||
1:
|
||||
# B
|
||||
2:
|
||||
# C
|
||||
3
|
||||
]
|
||||
|
||||
slice[
|
||||
# A
|
||||
1
|
||||
+ 2 :
|
||||
# B
|
||||
3 :
|
||||
# C
|
||||
4
|
||||
]
|
||||
x[1:2:3] # A # B # C
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue