This doesn't cover everything but it means it a lot of common usages the type will be slightly more useful
Co-authored-by: steve brazier <steve.brazier@trioptima.com>
The description, as it was, did not work with an older version of pip,
as the installation errored. An updated version of pip fixes the installation problem.
This replaces all uses of ‘blacklist’ with ‘exclude list’. Benefits:
- It is racially neutral terminology; see e.g. [1]
- It makes the meaning more clear. In fact, with the popular Python
autoformatter called ‘black’, also used by this project, files can be
‘blackened’ which is something completely different from them being on
a blacklist.
[1] https://chromium.googlesource.com/chromium/src/+/master/styleguide/inclusive_code.md#racially-neutral
According to the official docs, "user can be a system user name or a uid;
the same applies to group".
Co-authored-by: Artem Simonov <artem.simonov@dejero.com>
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 following code produces an error in mypy:
import asyncio
from asyncio.subprocess import PIPE
async def main() -> None:
proc = await asyncio.create_subprocess_shell("ls -l", stdout=PIPE)
assert proc.stdout is not None
async for line in proc.stdout:
print(line.decode())
await proc.wait()
asyncio.run(main())
$ mypy --strict file.py
file.py:8: error: "StreamReader" has no attribute "__aiter__" (not async iterable)
This commits fixes this by adding __aiter__/__anext__ methods that are
needed for async iterator protocol.
This is a follow-up on #4232. memoryview, hashlib, and hmac are updated
to use ReadableBuffer type instead of their own home-spun unions of
bytes, bytearray and whatever else each use case used. mmap is being
handled in #4244, and I'll leave BinaryIO for another day (or possibly
another person) because it's going to require some messy code
duplication because the relevant methods are defined in IO[AnyStr].
There's one corner case I'm not quite sure how best to handle: the
documentation for hmac.digest claim that the parmaeters have the same
meanings as in hmac.new, but in CPython the latter has an explicit check
that `key` is bytes or bytearray while the former works with a
memory-view. For now I've matched the documentation.
Also, the documentation for HMAC.update says that `msg` can be any type
supported by hashlib from Python 3.4; but I can't see anything in the
Python 2.7 implementation that would prevent it also taking bytes-like
objects, so I've not tried to treat Python 2 any different to Python 3.