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
Both are None if there were no groups matched. Also 'lastgroup'
will be None if the matched group was nameless.
The Python 2 versions of these annotations already used Optional.
* Add types and functions in types.py that are new in 3.7
* Update `resolve_bases` to accept any iterable of objects, and the same
for `new_class` if the version is at least 3.7
* Add comparison overrides implemented by MethodWrapperType
* Fix mypy error due to over-constrained `__eq__`
Morsel does cast any value to string and therfor any is the correct
typehint. For some keys other types then strings are more
appropiate anyway, max-age can take an integer (unix time) and http-only
a boolean.
Closes#3059
The Pull Request #1121 added the `AddressFamily` type to `socket.pyi`
for Python 3.4+, so constants such as `AF_INET` are correctly
represented as being an enum member rather than an int. The same is
true of the `SocketKind` enums in the `SOCK_*` family.
Various functions in the socket module can accept either an int
or an `AF_*` enum member as arguments, which is allowed by the
int argument type. However the `getaddrinfo` function returns an
`AddressFamily` member rather than an int in the first position
of its list members, so code that access enum specific members
such as the `name` attribute causes a typing error to be found.
This change corrects the return type of `getaddrinfo` but leaves
the family parameters as int, given that `AddressFamily` members
are `IntEnum` and only ever treated as `int`s internally.
This includes two things to sync up with recent runtime updates:
* Move `Final`, `@final`, `Literal`, and `TypedDict` to `typing` (`typing_extensions` still defines or re-exports them)
* Rename `@typing.runtime` to `@typing.runtime_checkable`, while keeping `@runtime` as a backwards-compatible alias in `typing_extensions`.