`--enable-error-code ignore-without-code` means that mypy will ignore any type: ignore comments that don't have mypy error codes. It doesn't appear to have any effect on type: ignore comments that mypy_test doesn't use (e.g. because they're pyright- or stubtest-specific).
`--strict-equality` means that mypy will raise errors if we do something silly like `if sys.version_info == "linux"`. flake8-pyi should also check this for us, but I don't see any reason not to have mypy check this as well.
* Run mypy on the 3.11 stdlib in CI, as a regression test for https://github.com/python/mypy/issues/12220
* Correct the docstring at the top of the file following the changes made in #7478
* Stop the test from crashing when run locally if there's an extra file/folder in the stubs directory.
* Fix `mypy_test.py` so that it actually tests the third-party stubs
* Upgrade to mypy 0.940
* Skip running mypy on `SQLAlchemy` stubs for now, to workaround a mypy crash.
Because we didn't set mypy's clean_exit parameter, it was exiting immediately after checking the stdlib, meaning `mypy_test.py` wasn't checking the third-party stubs at all.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* Remove --strict-optional: This has been the default since mypy 0.600.
* Remove --disallow-subclassing-any: When we subclass Any in typeshed,
we do so deliberately. This just causes us to add unncessary ignores.
Only print the mypy command twice per version: Once for the stdlib and
once for the stubs. Use a dummy /tmp path. Add a header for each tested
Python version and remove the Python version from the individual stubs.
* Mark stdlib modules with upper version bounds
* Add minus to all versions and enforce in check_consistent
* Fix check_consistent and mypy_test to work with new VERSIONS format
As requested by https://github.com/python/typeshed/issues/1526.
This addition takes mypy configuration from each distribution metadata file and constructs a single mypy.ini to run with. It assumes there is no mypy.ini but in case we ever need one, it would be simple to add these on top of an existing configuration file.
Might be relevant for #2852
As the issue did not really specify how the configuration would look, I added the following:
- You may add a mypy-tests section to the metadata file.
It looks like this:
[mypy-tests]
[mypy-tests.yaml]
module_name = "yaml"
[mypy-tests.yaml.values]
disallow_incomplete_defs = true
disallow_untyped_defs = true
- module_name can be of the form "a.*" like in mypy.ini.
- You can add several module sections for complex distributions with several modules.
- I added the '--warn-incomplete-stub' option since it is made specifically for typeshed runs. See docs.
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
* travis: run stubtest on py39, allowing failures
* travis: run mypy with python version 3.9
* boto.compat, base64: fix version handling of (en|de)codebytes
* venv: fix#4010
Co-authored-by: hauntsaninja <>
This runs mypy both with Python 3.7 and 3.8. In Python 3.8,
mypy switched from using typed-ast to using Python's built-in ast.
This patch ensures that both are tested.
This was already the configuration in Travis and it's been working fine. It's
confusing that Travis was using a different configuration than the default
when you run tests/mypy_test.py yourself.
* Add flags to pass on --warn-unused-ignores and --no-implicit-optional to mypy
* Make implicit Optional explicit in arg types (2and3 part)
* Convert {stdlib,third_party}/2 to explicit Optional
This simplifies running flake8 tests and reduces the amount of F821 errors
reported (flake8-pyi enables support for forward references in *.pyi files).
The error code is left disabled until I clean up the remaining issues.