mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-25 19:17:16 +08:00
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>
This commit is contained in:
@@ -5,6 +5,8 @@ tests the stubs with [mypy](https://github.com/python/mypy/)
|
||||
[pytype](https://github.com/google/pytype/).
|
||||
- `tests/pyright_test.py` tests the stubs with
|
||||
[pyright](https://github.com/microsoft/pyright).
|
||||
- `tests/regr_test.py` runs mypy against the test cases for typeshed's
|
||||
stubs, guarding against accidental regressions.
|
||||
- `tests/check_consistent.py` checks certain files in typeshed remain
|
||||
consistent with each other.
|
||||
- `tests/stubtest_stdlib.py` checks standard library stubs against the
|
||||
@@ -24,17 +26,15 @@ Run using:
|
||||
(.venv3)$ python3 tests/mypy_test.py
|
||||
```
|
||||
|
||||
The test has three parts. Each part uses mypy with slightly different configuration options:
|
||||
- Running mypy on the stdlib stubs
|
||||
- Running mypy on the third-party stubs
|
||||
- Running mypy `--strict` on the regression tests in the `test_cases` directory.
|
||||
The test has two parts: running mypy on the stdlib stubs,
|
||||
and running mypy on the third-party stubs.
|
||||
|
||||
When running mypy on the stubs, this test is shallow — it verifies that all stubs can be
|
||||
This test is shallow — it verifies that all stubs can be
|
||||
imported but doesn't check whether stubs match their implementation
|
||||
(in the Python standard library or a third-party package).
|
||||
|
||||
Run `python tests/mypy_test.py --help` for information on the various configuration options
|
||||
for this test script.
|
||||
for this script.
|
||||
|
||||
## pytype\_test.py
|
||||
|
||||
@@ -64,6 +64,13 @@ checks that would typically fail on incomplete stubs (such as `Unknown` checks).
|
||||
In typeshed's CI, pyright is run with these configuration settings on a subset of
|
||||
the stubs in typeshed (including the standard library).
|
||||
|
||||
## regr\_test.py
|
||||
|
||||
This test runs mypy against the test cases for typeshed's stdlib and third-party
|
||||
stubs. See the README in the `test_cases` directory for more information about what
|
||||
these test cases are for and how they work. Run `python tests/regr_test.py --help`
|
||||
for information on the various configuration options.
|
||||
|
||||
## check\_consistent.py
|
||||
|
||||
Run using:
|
||||
|
||||
Reference in New Issue
Block a user