Commit Graph

107 Commits

Author SHA1 Message Date
Nikita Sobolev
06d0151b25 Enable redundant-self mypy error code (#11056) 2023-11-22 10:13:17 +00:00
Nikita Sobolev
d232def6b2 Use consistent mypy output spacing (#11055) 2023-11-22 09:58:13 +00:00
Sebastian Rittau
7e2a3413fa Fix mypy_test if mypy returns negative exit code (#10866) 2023-10-11 14:53:16 +02:00
Ali Hamdan
c5dde1e720 Add optional requires_python field to third-party stubs metadata (#10724)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-09-24 18:39:12 +01:00
Alex Waygood
ef758b66c0 Bump mypy to 1.5.1 (#10559) 2023-08-16 12:18:31 -07:00
Sebastian Rittau
70d8d059a0 Make all tests executable (#10267) 2023-06-06 15:42:07 +02:00
Alex Waygood
2c3449694b Run mypy and pyright on our py312 stubs in CI (#10119) 2023-04-30 15:31:08 +01:00
Avasam
75f47d0cb1 Typecheck typeshed's code with pyright (#9793)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-02-22 18:53:07 +00:00
Avasam
140bba3425 Add comments when subclassing Any (#9732) 2023-02-14 14:11:56 +01:00
Alex Waygood
c216b74e39 Centralize METADATA.toml parsing in the test suite (#9534) 2023-01-28 15:13:46 +00:00
Alex Waygood
3d6b8dccfe mypy_test.py: Try using a process pool instead of a thread pool (#9556) 2023-01-17 14:17:45 +00:00
Avasam
1a9aa3f3fe Update various comments now non-types dependencies are allowed (#9527) 2023-01-14 13:20:04 +00:00
Alex Waygood
0b903441e8 Allow stubs to depend on numpy (#9499) 2023-01-12 09:01:23 +00:00
Alex Waygood
ab1921a737 Teach isort that imports from utils are first-party imports (#9500) 2023-01-11 17:25:32 +01:00
Alex Waygood
9aa3d99ac2 mypy_test.py: Add more comments (#9477)
Some fairly subtle logic was added in #9408, and I'm immediately regretting not having documented it slightly better. This PR adds some more comments to make maintaining this code easier in the future.
2023-01-08 12:26:11 -08:00
Alex Waygood
910397c714 mypy_test.py: Simplify add_third_party_files() (#9476) 2023-01-08 12:25:06 -08:00
Alex Waygood
4d6fda99f0 mypy_test.py: Allow non-types dependencies (#9408)
The approach is pretty similar to the approach I took in #9382 for regr_test.py: dynamically create virtual environments for testing stubs packages in isolation. However, since mypy_test.py tests all of typeshed's stubs in succession (and since lots of typeshed's stubs packages depend on other typeshed stubs packages), the performance issues with creating a virtual environment for testing each stubs package are even more severe than with regr_test.py.

I mitigate the performance issues associated with dynamically creating virtual environments in two ways:

- Dynamically creating venvs is mostly slow due to I/O bottlenecks. Creating the virtual environments can be sped up dramatically by creating them concurrently in a threadpool. The same goes for pip installing the requirements into the venvs -- though unfortunately, we have to use pip with --no-cache-dir, as the pip cache gets easily corrupted if you try to do concurrent reads and writes to the pip cache.

- If types-pycocotools requires numpy>=1 and types-D3DShot also requires numpy>=1 (for example), there's no need to create 2 virtual environments. The same requirements have been specified, so they can share a virtual environment between them. This means we don't have to create nearly so many virtual environments.
2023-01-07 23:57:49 +00:00
Alex Waygood
8671fc5c0f regr_test.py: Allow non-types dependencies (#9382) 2022-12-23 13:55:54 -08:00
Avasam
c6b9b4ce85 Stricter settings in mypy_test (#9294) 2022-12-02 18:55:55 +00:00
github-actions[bot]
5453c97753 Bump protobuf to 4.21.*; delete google/__init__.pyi (#8360)
This major version bump of the stubs package deletes google/__init__.py, which does not exist at runtime, and caused problems for several users. Mypy now has --namespace-packages enabled by default, which should hopefully mean that this causes minimal pain.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-11-25 11:28:56 +00:00
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