The following code works:
>>> print(sys.version)
2.7.16 (default, Mar 11 2019, 18:59:25)
>>> def f(): pass
>>> print(f.__code__)
<code object f at 0x7f8534ecc8a0, file "<stdin>", line 1>
>>> isinstance(f.__code__, types.CodeType)
True
but it didn't type-check with `mypy --python-version 2.7`.
This is a small cosmetic change. I want to encourage use of the
nicer-lookng pytype.config.Options.create() rather than
direct construction of the command-line args, so I'm changing
over all occurrences of the latter that I can find.
This runs mypy both with Python 3.7 and 3.8. In Python 3.8,
mypy switched from using typed-ast to using Python's built-in ast.
This patch ensures that both are tested.
* error is an alias for OSError in Python 3
* herror and gaierror can be constructed without arguments (tested
in Python 2.7 and 3.7)
* timeout uses the same arguments as herror and gaierror
This takes advantage of a recent mypy change to respect the return
type of `__new__`. Using that it does the same tedious overloads
as `run` and `check_output`.
This gives better types to `subprocess.check_output` and `subprocess.run`
by laboriously overloading using literals.
To support `run`, I turned `CompletedProcess` into `_CompletedProcess[T]`
with `CompletedProcess = _CompletedProcess[Any]`. I could pretty easily
be convinced that it would be better to just make `CompletedProcess`
generic, though.
I'd like to do the same for Popen but need to make mypy support
believing the type of `__new__` in order for that to work.
* Fix flask render_template and render_template_string stubs
* Add types for flask view function
* Import TracebackType from the right location
* Switch to bound typevar in route decorator stub
* Change render_template and render_template_string parameters to Text
The implementation of `logging.adapters.QueueHandler` and `logging.adapters.QueueListener` works great with `queue.SimpleQueue` too, so update the stub to reflect this.
The new queue.SimpleQueue class (introduced in 3.7) is faster but is not a Queue subclass as it doesn't implement task handling (`handle_task()` / `join()`) or queue bounds (raising `queue.Full` / `full()`). The logging handler / listener implementations do not make use of those features however.
Related Python bug, asking for an explicit documentation mention: https://bugs.python.org/issue37469