Until now I didn't know code like `if annotation is ...` is possible.
What will come next, using // as an operator?!
elif isinstance(annotation, typing.TypeVar):
return annotation.__name__, annotation.__name__
+ # Ellipsis -- print a literal `...`
+ # TODO: any chance to link this to python official docs?
+ elif annotation is ...:
+ return '...', '...'
+
# If the annotation is from the typing module, it ... gets complicated. It
# could be a "bracketed" type, in which case we want to recurse to its
# types as well.
<span class="m-doc-wrap-bumper">def <a href="#annotation_callable_no_args" class="m-doc-self">annotation_callable_no_args</a>(</span><span class="m-doc-wrap">a: typing.Callable[[], typing.Dict[int, float]])</span>
</dt>
<dd>Annotation with the Callable type w/o arguments</dd>
+ <dt id="annotation_ellipsis">
+ <span class="m-doc-wrap-bumper">def <a href="#annotation_ellipsis" class="m-doc-self">annotation_ellipsis</a>(</span><span class="m-doc-wrap">a: typing.Callable[[...], int],
+ b: typing.Tuple[str, ...])</span>
+ </dt>
+ <dd>Annotation with ellipsis</dd>
<dt id="annotation_func_instead_of_type">
<span class="m-doc-wrap-bumper">def <a href="#annotation_func_instead_of_type" class="m-doc-self">annotation_func_instead_of_type</a>(</span><span class="m-doc-wrap">a)</span>
</dt>
def annotation_callable_no_args(a: Callable[[], Dict[int, float]]):
"""Annotation with the Callable type w/o arguments"""
+def annotation_ellipsis(a: Callable[..., int], b: Tuple[str, ...]):
+ """Annotation with ellipsis"""
+
# Only possible with native code now, https://www.python.org/dev/peps/pep-0570/
#def positionals_only(positional_only, /, positional_kw):
#"""Function with explicitly delimited positional args"""