Fixes#4288.
- Default imports to THIRD_PARTY, so in effect we merge the FIRST_PARTY and THIRD_PARTY stubs. This means import order is no longer affected by whether typing_extensions is installed locally.
- Treat typing_extensions, _typeshed and some others as standard library modules.
Note that isort master is very different from the latest release; we'll have to do something
different if and when the next isort release comes out.
The SocketCAN BCM option flag constants were added in version 3.9,
and only backported to version 3.8, despite the documentation's claims
of supporting all BCM-related constants starting from version 3.4.
Note: The CAN_FD_FRAME flag option was only introduced in the 4.8.x
kernel series, while the rest of the constants were available since the
Broadcast Manager was mainlined in the kernel as part of the SocketCAN
patches.
* Add new socket constants from 3.7 and 3.8
* Also move TCP_NOTSENT_LOWAT to 3.7 section and add AF_ALG to AddressFamily
* Add missing and updated socket module (and class) methods
* Improve formatting of socket.pyi
* Add missing line breaks in long function parameters
* Reorder to mirror module documentations
* Fix type of create_server's family parameter
* Add more system conditionals
* Remove CAPI; it isn't an int (it's a PyCapsule)
* Slightly improve version conditions in socket.pyi
* Add incomplete signatures for socket.sendfile and .sendmsg_afalg
* Add VM_SOCKETS_INVALID_VERSION to socket.pyi
* Remove private _GLOBAL_DEFAULT_TIMEOUT from socket.pyi
* Add mode-dependent return types to socket.makefile
- For Python 2, return and mode types are based on those of 'open'
- For Python 3, types are based on actual behaviors
* Mark recv_into and recvfrom_into's nbytes argument as optional
* Improve docstring for socket stub
* Add os.add_dll_directory()
* Add memfd_create() and flags
* Add type annotation to flags
* Add stat_result.st_reparse_tag and flags
* Add ncurses_version
* Add Path.link_to()
* Add Picker.reducer_override()
* Add plistlib.UID
* Add has_dualstack_ipv6() and create_server()
* Add shlex.join()
* Add SSL methods and fields
* Add Python 3.8 statistics functions and classes
* Remove obsolete sys.subversion
* Add sys.unraisablehook
* Add threading.excepthook
* Add get_native_id() and Thread.native_id
* Add Python 3.8 tkinter methods
* Add CLOCK_UPTIME_RAW
* Add SupportsIndex
* Add typing.get_origin() and get_args()
* Add unicodedata.is_normalized
* Add unittest.mock.AsyncMock
Currently this is just an alias for Any like Mock and MagicMock. All of
these classes should probably be sub-classing Any and add their own
methods. See also #3224.
* Add unittest cleanup methods
* Add IsolatedAsyncioTestCase
* Add ElementTree.canonicalize() and C14NWriterTarget
* cProfile.Profile can be used as a context manager
* Add asyncio task name handling
* mmap.flush() now always returns None
* Add posonlyargcount to CodeType
I realized while working on srittau/type-stub-pep#64 that a
few things we do in existing enum definitions in typeshed are
problematic:
- Using "= ..." doesn't allow type checkers to correctly type the
result of Enum.MEMBER.value. In fact, mypy at least infers
.value to be "Ellipsis" if you do this.
- Properties on the enum values themselves, like HTTPStatus.phrase,
should not be specified directly as attributes, because it makes
type checkers think that the properties themselves are enum
members.
I ended up doing a bit more cleanup to the signal module:
- Remove unnecessary ... initializers.
- Remove unnecessary _SIG = Signals alias.
- I don't have Windows to test, but the C code for _signal suggests
that CTRL_C_EVENT and CTRL_BREAK events are not Signals, but just ints:
1dbd084f1f/Modules/signalmodule.c (L1575)
* 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
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.
* Add new methods to socket stubs.
Also fix a couple of invalid types in recv*_into() socket methods.
* Add double-underscores to parameters for position-only arguments