mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
The ellipsis literal (`...`) can be used in multiple contexts: - Placeholders: `class Foo: ...` - Containers: `Tuple[int, ...]` - Assignments: `x = ...` This is a trickier pattern to match because we can't rely on keyword boundaries, so we instead look for exactly three dots (`...`). This does mean that we will match the `...` portion of `x...x`, which isn't valid Python syntax, but I think that's an acceptable trade-off that avoids making this pattern much more complex. Reference: - https://docs.python.org/3/library/constants.html#Ellipsis closes: #18107 Signed-off-by: Jon Parise <jon@indelible.org> Signed-off-by: Christian Brabandt <cb@256bit.org>
44 lines
641 B
Python
44 lines
641 B
Python
# Ellipsis Literal
|
|
# https://docs.python.org/3/library/constants.html#Ellipsis
|
|
|
|
# Placeholders
|
|
...
|
|
...
|
|
x = ...
|
|
y = ... # Comment
|
|
class C: ...
|
|
lambda: ...
|
|
|
|
# Annotations
|
|
numbers: Tuple[int, ...]
|
|
|
|
# Doctests
|
|
"""A doctest
|
|
|
|
>>> class A:
|
|
... def __init__(self):
|
|
... ...
|
|
>>> class B: ...
|
|
>>> x = ...
|
|
>>> raise ValueError('multi\n line\ndetail')
|
|
Traceback (most recent call last):
|
|
...
|
|
ValueError: multi
|
|
line
|
|
detail
|
|
>>> print(list(range(20))) # doctest: +ELLIPSIS
|
|
[0, 1, ..., 18, 19]
|
|
>>> exec(s) #doctest: +ELLIPSIS
|
|
-3.21716034272e-0...7
|
|
"""
|
|
|
|
class C:
|
|
"""
|
|
>>> class C:
|
|
... def __init__(self):
|
|
... ...
|
|
"""
|
|
|
|
# Numpy
|
|
x[..., 0]
|