Commit Graph

87 Commits

Author SHA1 Message Date
Samuel T 573ee94f35 All scripts/tests: always specify file encoding in calls to open() (#8882) 2022-10-11 22:29:36 +01:00
Alex Waygood e73fcf220e mypy_test.py: Remove unused seen variable/parameters (#8846) 2022-10-04 14:38:31 -07:00
Alex Waygood 55cddc7ac7 mypy_test.py: restore previous behaviour where all third-party stubs are tested by default (#8842) 2022-10-04 11:01:51 -07:00
Alex Waygood 5da171ba45 mypy_test.py: Always add dependencies of stubs to the files to test (#8800) 2022-10-04 08:05:13 -07:00
Alex Waygood ab2fba9c83 check_consistent.py: ignore .gitignored files (#8804) 2022-09-28 17:02:27 +01:00
Alex Waygood 48e76e8a56 Bump mypy to 0.981 (#8796) 2022-09-26 17:14:33 -07:00
Alex Waygood 008fe2e764 mypy_test.py: rework filter, exclude and --dir arguments (#8711) 2022-09-22 08:31:24 +01:00
Alex Waygood b53843ab46 Add infrastructure allowing for test cases for third-party stubs (#8700)
- Move the logic for running mypy on the test cases from `tests/mypy_test.py` to a separate script, `tests/regr_test.py`.
- Add the necessary logic in order to be able to have test cases for third-party stubs.
- Move logic common to `tests/mypy_test.py` and `tests/regr_test.py` into `tests/colors.py`, and rename `tests/colors.py` to `tests/utils.py`.
- Add a new check to `tests/check_consistent.py`, to enforce the use of `# pyright: reportUnnecessaryTypeIgnoreComment=true` comments in third-party test cases. These are essential if we want to have our tests against false-negatives work with pyright.
- Update the relevant documentation to account for the new test file.
- Add a new job to the `tests.yml` GitHub workflow, to run the new test in CI.
- Add a simple proof-of-concept test case for `requests`, as a regression test for #7998.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
2022-09-08 16:51:33 +01:00
Alex Waygood b6d28acb23 mypy_test.py: Use pathlib more (#8680) 2022-09-05 14:24:14 +01:00
Alex Waygood 1c56148ce9 mypy_test.py: Remove --dry-run option (#8611)
Cf #8139.
2022-08-25 14:23:00 +02:00
Nipunn Koorapati c697a51378 Support tests/mypy_test.py [package] (#8610)
Currently, the testsuite early exits if it's filtering on a single
package. With this change, it will correctly complete.

For example `tests/mypy_test.py protobuf`
2022-08-25 12:25:26 +01:00
Alex Waygood 875f0ca7fc mypy_test.py: Move type-checking of our tests and scripts into a different test (#8587) 2022-08-22 17:16:03 +01:00
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