Description
Feature or enhancement
There are multiple examples that are very similar to doctests, but are not doctests.
I propose adding >>>
and ...
to them, so these examples would be checked during tests (since now we have this feature).
There are some easy ones, where just adding >>>
(and some imports are enough).
There are also some more complex ones, where some new types / vars are needed, but I don't think it is worth doing, because it will increase the complexity of these examples.
Examples:
Lines 207 to 217 in 0ee2d77
Lines 252 to 259 in 0ee2d77
Lines 672 to 686 in 0ee2d77
Lines 2239 to 2255 in 0ee2d77
Lines 2268 to 2280 in 0ee2d77
Lines 2293 to 2304 in 0ee2d77
Lines 2899 to 2909 in 0ee2d77
This actually reveals a bug:
Lines 207 to 219 in 0ee2d77
assert collections.abc.Callable[ParamSpec, str].__args__ == (ParamSpec, str)
example is invalid:
File "/Users/sobolev/Desktop/cpython2/Lib/typing.py", line 218, in typing._should_unflatten_callable_args
Failed example:
assert collections.abc.Callable[ParamSpec, str].__args__ == (ParamSpec, str)
Exception raised:
Traceback (most recent call last):
File "/Users/sobolev/Desktop/cpython2/Lib/doctest.py", line 1374, in __run
exec(compile(example.source, filename, "single",
File "<doctest typing._should_unflatten_callable_args[2]>", line 1, in <module>
assert collections.abc.Callable[ParamSpec, str].__args__ == (ParamSpec, str)
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
File "/Users/sobolev/Desktop/cpython2/Lib/_collections_abc.py", line 477, in __new__
raise TypeError(f"Expected a list of types, an ellipsis, "
TypeError: Expected a list of types, an ellipsis, ParamSpec, or Concatenate. Got <class 'typing.ParamSpec'>