-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
add type annotations #152
Comments
Thanks for the suggestion @chdsbd. I think this would be best when |
There are some reasonable workarounds to this problem. Right now I have a test like this:
When I run it through mypy, I get the following error:
Workaround #1 - Ignore the error
Workaround #2 - Use the result of the patch command.
|
FWIW, I have just opened python/typeshed#4275. This will add stubs to typeshed for now. Of course, I'd be glad to see the stubs in pytest-mock directly some day, either via separate stub files or inline. |
@srittau What gets priority when a package has its own stubs, and is also defined in typeshed? |
@bluetech stub packages get priority, see https://www.python.org/dev/peps/pep-0561/#type-checker-module-resolution-order. |
Thanks @JelleZijlstra. So it should be fine if we ever decide to ship type annotations inline. |
As soon as that happens, we should remove the stubs from typeshed anyway, to avoid confusion and reduce typeshed's maintenance burden. |
Pytest 6.0 now supports type annotations and pytest-mock is now python3.5+ 👀 |
In #194 we now run The next step would probably be to type annotate the public API and export a |
Now we explicitly ignore specific imports instead of a blanket ignore on all missing types. Upgraded databases and pytest to get their latest versions which include types, for the rest we're ignoring them explicitly. see #485 - arrow doesn't have types but we can replace it with std library calls - requests_async deprecated in favor of httpx, so we'd need to upgrade to get types. The API of httpx is a little different as well. - structlog doesn't have types currently hynek/structlog#165 - rure No stubs yet davidblewett/rure-python#23 - pytest_mock types recently added to the typeshed so we'll need to wait for the next release of mypy. pytest-dev/pytest-mock#152 - markdown_html_finder Wrapper around some Rust code. Needs stubs to be added. chdsbd/markdown-html-finder#5 - asyncio_redis We're our own fork of it, but adding types would be rather manual. Granted we aren't using that much of the API surface. https://github.com/chdsbd/asyncio-redis - zstandard No stubs yet, so we're ignoring for the time being indygreg/python-zstandard#120 - inflection Types, but I think they're misconfigured, once they're fixed we can unignore. jpvanhal/inflection#49 - django Need to setup django-stubs for this to work since django doesn't have any static types. https://github.com/TypedDjango/django-stubs - dj_database_url Doesn't have any static types yet jazzband/dj-database-url#135 - responses No types yet getsentry/responses#339 - stripe Plan for types, but they don't exist currently stripe/stripe-python#650
Now we explicitly ignore specific imports instead of a blanket ignore on all missing types. Upgraded databases and pytest to get their latest versions which include types, for the rest we're ignoring them explicitly. see #485 - arrow doesn't have types but we can replace it with std library calls - requests_async deprecated in favor of httpx, so we'd need to upgrade to get types. The API of httpx is a little different as well. - structlog doesn't have types currently hynek/structlog#165 - rure No stubs yet davidblewett/rure-python#23 - pytest_mock types recently added to the typeshed so we'll need to wait for the next release of mypy. pytest-dev/pytest-mock#152 - markdown_html_finder Wrapper around some Rust code. Needs stubs to be added. chdsbd/markdown-html-finder#5 - asyncio_redis We're using our own fork of it, but adding types would be rather manual. Granted we aren't using that much of the API surface. https://github.com/chdsbd/asyncio-redis - zstandard No stubs yet, so we're ignoring for the time being indygreg/python-zstandard#120 - inflection Types, but I think they're misconfigured, once they're fixed we can unignore. jpvanhal/inflection#49 - django Need to setup django-stubs for this to work since django doesn't have any static types. https://github.com/TypedDjango/django-stubs - dj_database_url Doesn't have any static types yet jazzband/dj-database-url#135 - responses No types yet getsentry/responses#339 - stripe Plan for types, but they don't exist currently stripe/stripe-python#650
Fix #152 Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
pytest-mock is now type annotated, which makes typeshed's annotations obsolete. See pytest-dev/pytest-mock#152.
pytest-mock is now type annotated, which makes typeshed's annotations obsolete. See pytest-dev/pytest-mock#152.
I think it may be helpful to add type annotations to this package.
The text was updated successfully, but these errors were encountered: