Commit Graph

75 Commits

Author SHA1 Message Date
Alex Waygood
38bc0ec0e6 mypy_test.py: simplify argument parsing (#8577) 2022-08-20 21:32:17 +01:00
Kevin Kirsche
bd7a02fad4 refactor: prefer f-strings to other format/concatentation styles (#8474) 2022-08-03 14:04:27 +02:00
Sebastian Rittau
ef443b6359 Re-enable SQLAlchemy mypy tests (#8282)
These used to crash if run twice in succession locally, but the crash has been fixed on mypy 0.971
2022-07-19 16:46:39 +01:00
Alex Waygood
78d96cd17e Drop support for Python 2 (#8272) 2022-07-12 09:08:56 +02:00
Sebastian Rittau
9a5c865034 Drop support for Python 3.6, part 1 (#8250)
* Document that typeshed support 3.7+.
* Don't run tests on Python 3.6.
* Remove Python 3.6 allow lists.
* Merge common allowlist items.

Part of #6189
2022-07-07 14:42:02 +02:00
Alex Waygood
64d91ef414 mypy_test.py: Add command-line argument to enable selecting which parts of the test to run (#8143) 2022-06-23 10:21:32 -07:00
Alex Waygood
610d2908bd mypy_test.py: Allow passing in multiple platforms from the command line (#8138) 2022-06-22 20:13:01 +01:00
Alex Waygood
15a17d1301 mypy_test.py: Add argument validation, improve type hints (#8135) 2022-06-22 18:03:29 +01:00
Alex Waygood
09141ec3dc mypy_test.py: Fix argument-parsing for --python-version (#8134)
* mypy_test.py: Fix argument-parsing for `--python-version`

* Bump min version required in the README
2022-06-22 15:08:56 +01:00
Alex Waygood
a527bf27d5 Run mypy on the scripts directory in CI (#8133) 2022-06-22 14:13:38 +01:00
Alex Waygood
5fa31e6759 Remove mypy error codes from the test_cases directory (#8083) 2022-06-15 15:31:45 +01:00
Alex Waygood
8e8176b24c mypy_test.py: Skip Flask-SQLAlchemy (#7977) 2022-05-28 10:18:57 -07:00
Alex Waygood
aa72cb1dcf Run pyupgrade on the tests directory (#7880) 2022-05-19 14:16:53 +01:00
Alex Waygood
44d33f2fdb Add colour to the output of mypy_test, take 2 (#7879)
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
2022-05-19 13:29:15 +01:00
Alex Waygood
a348dac6e7 Revert "Add colour to the output of mypy_test" (#7874)
Revert "Add colour to the output of `mypy_test` (#7872)"

This reverts commit 753eb053ac.
2022-05-18 17:13:06 -07:00
Alex Waygood
753eb053ac Add colour to the output of mypy_test (#7872)
And gracefully exit on KeyboardInterrupt.
2022-05-19 00:36:59 +01:00
Alex Waygood
a98a1ead06 Improve output of mypy_test when reporting errors (#7863) 2022-05-18 19:10:54 +01:00
Alex Waygood
bb39bdfd30 Add test cases for pow that are meant to fail a type check (#7760) 2022-05-08 08:16:37 -07:00
Alex Waygood
c6b3211afa Improve test-suite documentation (#7756)
- mypy_test and pyright no longer just test the stubs, they now also test other parts of typeshed as well.
- pytype_test.py can now be run on 3.10, meaning the whole test suite can now also be run on 3.10.
- Various test scripts now have from `__future__ import annotations`, meaning they can now only be run on 3.7+.
- Clean up the description of pyright_test.py, which had a slightly confusing wording.
- Also fix the `--dry-run` config option in mypy_test.py, which I accidentally broke in #7746
2022-04-30 12:43:48 -06:00
Alex Waygood
8b118b236d Run mypy on the test cases and test scripts (#7746) 2022-04-30 06:39:07 -06:00
Alex Waygood
9d450cb50c Make test scripts pass mypy --strict (#7745)
- Add several type hints to untyped functions.
- While we're at it, upgrade several annotations to use modern syntax by using `from __future__ import annotations`. This means that the tests can't be run on Python 3.6, but 3.6 is EOL, and it is already the case that some scripts in this directory can only be run on more recent Python versions. E.g. `check_new_syntax.py` uses `ast.unparse`, which is only available in Python 3.9+.
- Fix a few pieces of code that didn't type check.
2022-04-29 21:55:12 -06:00
Alex Waygood
002c8e2586 Cleanup mypy_test.py (#7738) 2022-04-28 12:00:54 -06:00
Sebastian Rittau
f7aa41245e Drop Python 2 support in third-party stubs (#7703) 2022-04-27 15:32:17 +03:00
Alex Waygood
478e7527aa mypy_test: Add two more config options (#7560)
`--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.
2022-03-28 16:06:13 +01:00
Alex Waygood
2f338ce077 Further improve mypy_test.py (#7484)
* 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.
2022-03-13 19:58:30 +00:00
Jelle Zijlstra
fa332220b7 Fix mypy test (#7478)
* 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>
2022-03-13 13:01:14 +00:00
Sebastian Rittau
c3907ab26b Remove Python 2 support from some third-party distributions (#7466)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-03-09 20:19:22 +02:00
Nikita Sobolev
09395dd747 Add --disallow-untyped-decorators to mypy_test (#7235) 2022-02-16 01:47:52 -08:00
Sebastian Rittau
bf246b28a9 Update to mypy 0.921 (#6657)
Test third-party stubs with typeshed from mypy
2021-12-22 07:57:07 -08:00
Jelle Zijlstra
1f1bc6f27c add pre-commit config (#6341)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Akuli <akuviljanen17@gmail.com>
2021-11-19 16:46:51 +02:00
Sebastian Rittau
77810277d5 Recommend to use mypy error codes if applicable (#6305) 2021-11-17 21:58:05 -08:00
Sebastian Rittau
bcc743dd2b mypy_test: Skip files starting with '.' (#6306) 2021-11-16 17:00:39 +02:00
Sebastian Rittau
edf82e8094 Clean up mypy flags (#6308)
* 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.
2021-11-16 12:58:53 +00:00
Sebastian Rittau
e22b63d9cc Reduce mypy_test output (#6268)
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.
2021-11-09 18:03:29 +01:00
Sebastian Rittau
3876587a65 Remove support for mypy_exclude_list (#6230) 2021-11-08 10:45:46 +02:00
Sebastian Rittau
50c1f2ab7c Test third-party stubs in isolation (#6229) 2021-11-07 15:05:49 -08:00
Nikita Sobolev
392c81d767 Switch from toml to tomli (#6023) 2021-09-10 15:48:15 +02:00
Sebastian Rittau
7c382c7cd8 Run mypy tests for stdlib and third-party separately (#5760) 2021-07-12 10:09:13 +02:00
Akuli
11b99e1141 @python2 nits (#5672)
* tiny tests/mypy_test.py cleanup

* try to make CONTRIBUTING.md less confusing
2021-06-21 21:42:45 +03:00
Sebastian Rittau
68dc2d132b Move Python 2-only stubs to @python2 directory (#5660) 2021-06-21 11:28:25 -07:00
Sebastian Rittau
54a0bd80ee Add a comment about _typeshed to VERSIONS (#5447) 2021-05-19 11:01:33 +02:00
Sebastian Rittau
35acd2ad6f check_consistent: allow dots in module names (#5472) 2021-05-16 11:01:00 -07:00
Sebastian Rittau
1eb64b4372 Mark stdlib modules with upper version bounds (#5394)
* 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
2021-05-10 16:29:43 +03:00
Akuli
9f732a128a enable mypy_test for python 3.10 (#5341)
* enable mypy_test for python 3.10

* avoid collections.Mapping and collections.MutableMapping, import from typing
2021-05-05 00:09:33 +03:00
hatal175
fd2a176094 Allow per distribution mypy strictness options (#5169)
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.
2021-04-07 21:30:08 -07:00
Ivan Levkivskyi
16ae4c6120 Re-organize directory structure (#4971)
See discussion in #2491

Co-authored-by: Ivan Levkivskyi <ilevkivskyi@dropbox.com>
2021-01-27 12:00:39 +00:00
Shantanu
a93fa6120e mypy_test: fix for stub deletions (#4816)
I think this should helps prevent issues like #4815

Co-authored-by: hauntsaninja <>
2020-12-13 23:41:20 -08:00
Shantanu
48970d31de tests / scripts: blacken and isort (#4704)
I often run black and isort in typeshed root and then have to undo these
changes.

Co-authored-by: hauntsaninja <>
2020-10-25 11:21:03 +01:00
wouter bolsterlee
3efb675dba Use ‘exclude list’ instead of ‘blacklist’ (#4297)
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
2020-07-01 09:10:37 +02:00
Shantanu
997c73ae79 travis: start testing 3.9 somewhat (#4071)
* 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 <>
2020-05-24 18:45:16 -07:00