generated from tophat/new-project-kit
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mark as PEP 561 (type checking) compatible #439
Comments
huonw
added a commit
to huonw/syrupy
that referenced
this issue
Dec 1, 2020
This follows PEP-561 to mark syrupy as compatible with type checking (driven by the type annotations that already exist and are checked), by creating an empty `py.typed` in the project. This stops users from having to ignore syrupy when type checking, and allows the type checker to provide specific guidance about possible problems. Fixes syrupy-project#439
3 tasks
noahnu
pushed a commit
that referenced
this issue
Dec 1, 2020
* feat: add PEP-561 py.typed file for downstream type checkers This follows PEP-561 to mark syrupy as compatible with type checking (driven by the type annotations that already exist and are checked), by creating an empty `py.typed` in the project. This stops users from having to ignore syrupy when type checking, and allows the type checker to provide specific guidance about possible problems. Fixes #439
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
MyPy and other static type checkers are helpful for validating code. Currently syrupy doesn't work perfectly in projects that use mypy, because it is not considered PEP 561 compatible: https://mypy.readthedocs.io/en/latest/installed_packages.html#making-pep-561-compatible-packages
This means that something like:
fails with
The fix for users for this is ignoring the imports (as described in the link there), such as
from syrupy.assertion import SnapshotAssertion # type: ignore
. However, this is unfortunate because it stops mypy and potentially other tooling from picking up the error:match
instead ofmatcher
.Describe the solution you'd like
By adding a
py.typed
file as described in https://mypy.readthedocs.io/en/latest/installed_packages.html#making-pep-561-compatible-packages , the existing type annotations become available to mypy users.The output of the above then becomes:
Describe alternatives you've considered
A separate stub file/project seems unnecessary, given there's already type annotations inline in the code.
Additional context
N/A
The text was updated successfully, but these errors were encountered: