Correctly detects calls to `register()` with a function of incompatible return
type. Correctly recognizes the `register()`, `dispatch()`, and
`_clear_cache()` methods on a generic function, as well as the `registry`
mapping.
Possible future improvements: it would be amazing if `register()` checked if
the first argument of the registered callable is indeed of valid type. This
would require Callable[] to support varargs. It would also be great if we
could read the arguments of the remaining arguments during `@singledispatch()`
and cross-check them during `register()` with the currently registered
implementation. Again, this would require Callable[] to become much more
advanced.
Several asyncio AbstractEventLoop methods take a callback as
an argument that is passed *args. The Callable definition was
incorrect for those callbacks.
```
$ python3.4
Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> list(filter(None, [False, True]))
[True]
>>>
```
* Add `None` to type union for `subprocess.Popen.communicate` stub's `input` parameter.
* subprocess.communicate `input` annotated as `Optional[AnyStr]` for both 2.7 and 3.x; `timeout` as `Optional[float]`.
- Cursor is an Iterator of Any now, and .__iter__(..) and .__next__(..)
have been changed / made explicit to reflect this.
- .fetchall(..)/.fetchmany(..)/.fetchone(..) return (lists of) Anys
instead of tuples.
As per discussion in PR #663, the output of fetching values from the
cursor can be customized with a custom assignment to
.row_factory. Therefore the correct return type for fetching is Any and
not tuple.
I added strong types to the class that users are likely to interact with and left
the rest untyped for now. This is needed to support Flask.
Permission is given here - https://github.com/pallets/flask/issues/2012
* add stubs for Python 2 profile and cProfile
Partially fixes#531. Contrary to the Python 2.7 docs at
https://docs.python.org/2/library/profile.html#module-cProfile,
these modules do not have exactly the same interface. For
example, profile.Profile() does not have an enable() method.
* profile stubs: move to 2and3, add __init__, use private names for typevars
I'm preparing a PR to mypy that further formalizes and improves the rules for
which functions are "compatible" with each other, both for subtyping and for
assignment. This is the one place in the stubs that violates the new rules but
not the old: the supertype `Serializer` can take an optional positional argument
called `serializer` to `load_payload`, but until this diff the mixin used to
implement it could not, but rather could only take `serializer` as a named
argument, through its **kwargs.
Fixes#720.
Related changes: used a NamedTuple for time.struct_time on Python 3, used
sys.version selectors for proper typing of #716, added missing *Style classes
to logging on Python 3.