* Add script to generate protoc stubs using mypy-protobuf generated stubs
* Use generate_proto_stubs to generate stubs for protobuf 3.14.0
* Skip _pb2.pyi from flake8,black,isort,pytype
[tests/pytype_test.py](./tests/pytype_test.py#L176) is still using
Python `3.6`:
> python_version="2.7" if version == 2 else "3.6",
The test fails to run if `python3.6` is unavailable (for example on
Debian 10 Buster, which has 3.7).
According to (https://devguide.python.org/#status-of-python-branches
`3.6` is still maintained until end of 2021.
`pytype` itself [claims](https://github.com/google/pytype#requirements)
to run on `2.7`, `3.5`-`3.8`.
Change the script to use the version of Python from the invoking
interpreter.
The previous typing meant `threading.ExceptHookArgs` could not be used
to type a value.
The new typing follows what cpython does in the happy path (`_thread`
exists rather than the pure-python fallback being used).
Fixes#4767.
* typeshed: update stubtest version
Includes changes from https://github.com/python/mypy/pull/9680
I've already fixed all the true positives on typeshed.
* attempt to fix windows' _WarnFunction
Co-authored-by: hauntsaninja <>
Only a subset of mypy's test suite should be relevant to typeshed:
https://github.com/python/mypy/pull/9638
This should make things faster.
(Also the -n12 argument to pytest is weird; note mypy's pytest.ini
automatically specificies -nauto which is what we should want)
Resolves https://github.com/python/typeshed/issues/4333
Co-authored-by: hauntsaninja <>
In #4696 I bumped stubtest to a commit that hasn't been released. We
should have these stubtest versions match. In
https://github.com/python/mypy/pull/9426 I changed the output of
stubtest here; it's good to get this change in before I forget and this
action silently stops working.
Co-authored-by: hauntsaninja <>
platform.DEVNULL seemed undocumented, but is eg, still mentioned in the
header comment of platform.py. So feels surprising this was removed
without much warning.
Co-authored-by: hauntsaninja <>
The latest pytype release fixes two pyi parser bugs that allow files
affected by them to be taken off the pytype exclude list. I removed two
`total=False` declarations in tkinter/__init__ that pytype does not like
(because it checks that `total` is present only when TypedDict is a
class's immediate parent) and which shouldn't be needed because
_InMiscNonTotal already specifies totality. I double-checked that mypy
reports no errors in 3.7 on a .py file containing:
from typing_extensions import TypedDict
Foo = TypedDict('Foo', {'x': int}, total=False)
class Bar(Foo): pass
x: Foo = {}
showing that it doesn't require `total` to be repeated.
In tkinter, `widget['foo'] = bar` and `widget.config(foo=bar)` do the same thing, but they will now type-check differently: the `widget['foo'] = bar` syntax allows 'foo' to be any string (e.g. a variable, not necessarily a Literal) and bar to be any object, while `widget.config(foo=bar)` checks the existence of the option and the type of bar. Similarly, cget takes a Literal argument but __getitem__ takes a string.
Testing script can still be found at c42a72c53e
* Removed imported symbols that are not accessed or re-exported from within third_party stubs (part 4). These were all identified as unused symbols by the pyright type checker and language server.
Co-authored-by: Eric Traut <erictr@microsoft.com>
This makes mypy think that conditions like
parameter.kind is Parameter.POSITIONAL_OR_KEYWORD
are always false, which triggers `unreachable` warnings, among other
problems.
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