As brought up in https://github.com/python/typeshed/pull/5516
Alternatives include:
- Use another type var that has a value restriction
- Doing something fancy with Protocols that have a __bool__ that returns
a Literal (which may not work)
- Doing nothing
* Move socket from AbstractServer to Server.
* Fix Server.socket type on Python 3.7+.
* Use Iterable instead of list for socket argument.
Closes: #5535
* mock: fix overloads
Fixes#5533. This changes the order and in some cases removes default
values from new.
* ignore incompatible overlaps
Co-authored-by: hauntsaninja <>
Add operators or and ror for types.Union and ror to the type class.
Also, add modified isinstance and issubclass signatures to support old-style and new-style unions inside.
Noticed this in mypy-primer output in #5516 on this code: https://github.com/encode/starlette/blob/master/starlette/testclient.py#L74
It calls `iscoroutinefunction()` on an object that may be None, which got flagged as an error but is actually fine; it just returns False.
We could also potentially use TypeGuard here, especially for `iscoroutine` which is just an `isinstance` call.
These are the pure-Python pickle implementation, and are sometimes used
by code that wants to extend or override parts of the
pickling/unpickling process.
* Remove explicit Iterable super class
* Use Literals for mode parameters
* Import from collections.abc
* Use protocols for TarFile(fileobj=) and Tarfile.gzopen()
* Use object instead of Any as protocol return types
* Replace all uses of StrPath, BytesPath, and AnyPath in Python 2 stubs.
* Add StrOrBytesPath as preferred alias for AnyPath.
* Replace all remaining AnyPath instances with StrOrBytesPath.
* Mark AnyPath as obsolete.
Part of #5470
* Make _TemporaryFileWrapper generic on AnyStr, use it
Previously it was not used on NamedTemoraryFile and thus the file
field was missing from the types for the return value of
NamedTemoraryFile.
* run script and do some manual changes (Akuli)
* do the whole thing manually (srittau)
* merge changes (Akuli)
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>