mypy_test
Test mypy plugins, stubs, custom types.
Create a Python file, add comments to lines where you expect mypy to produce an error, run mypy_test, and it will check if actual errors are the same as you expect.
Features:
- Flexible: supports every feature supported by mypy, does not enforce a project structure.
- Fast: mypy gets run only once for all files at once. Also, no patching, no config generation.
- Easy to learn: run
mypy_testwith the same arguments as you would run mypy, and it just works. - Lightweight: no dependencies except mypy.
python3 -m pip install mypy-test
Usage
-
Write a file you want to test, add comments to the lines you expect to fail:
a = 1 reveal_type(a) # R: builtins.int
-
Run the tool:
python3 -m mypy_test example.py
Writing the comments
- The comments have the following format:
SEVERITY: MESSAGE. - Severity is a one-letter violation severity as reported by mypy.
Ffor "fatal"Efor "error"Wfor "warning"Nfor "note"Ris a shorthand forN: Revealed type is "..."
- Comment can be on the same line as the violation or on the line before.
Example:
var = 1.1
reveal_type(var) # R: builtins.float
# E: Incompatible types in assignment (expression has type "str", variable has type "float")
var = ""
Tips:
- The fastest way to know the severity and the message is to run
mypy_teston the code and then copy-paste the resulting message. - Make separate functions for every test case, so it can have a nice description and a clean namespace.
- Place all test files into one directory. For example,
/types/or/tests/types/.
Alternatives
- pytest-mypy-plugins - pytest plugin, test cases described in a YAML file.
- pytest-mypy-testing - pytest plugin, tests are described like pytest test cases (but they actually don't get run).
Metadata
Release files for mypy-test 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mypy_test-0.1.4.tar.gz | 7.9 kB | Without provenance | Details for mypy_test-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mypy_test-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for mypy_test-0.1.4-py3-none-any.whl |
Total release size: 15.6 kB
Release files / mypy_test-0.1.4.tar.gz
| Download URL | mypy_test-0.1.4.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
57519efe3fd23041e076f22c7dcf927a7bd542f5c07c374db5d8638417ad24ab
|
|
BLAKE2b-256 checksum How to use checksums |
fe428827ad0c9b956b070554e82c71c382090c4fc35cf09d3488eab09eb270b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|
Release files / mypy_test-0.1.4-py3-none-any.whl
| Download URL | mypy_test-0.1.4-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce6bc363baefd766f4aae47eaee9bea6261feec6d0cd556efdf2386a02592871
|
|
BLAKE2b-256 checksum How to use checksums |
101ed4b27126507c4299c126159f61c29b6ec925ecf9d35d210fe7b88ebab641
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|
Security for mypy-test 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.