Skip to content

Mypy checking fails with --disallow-untyped-decorators #7589

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

Closed
squaresmile opened this issue Jul 30, 2020 · 1 comment
Closed

Mypy checking fails with --disallow-untyped-decorators #7589

squaresmile opened this issue Jul 30, 2020 · 1 comment
Labels
topic: typing type-annotation issue type: enhancement new feature or API change, should be merged into features branch

Comments

@squaresmile
Copy link

It looks like the @pytest.mark.parametrize decorator can't pass mypy with --disallow-untyped-decorators. mypy works without the flag.

Following my comment, I made this reproduction repo. I can reproduce this with pytest 6.0.1 and Python 3.6.9 on Linux or Python 3.8.5 on Windows.

> mypy test_mypy.py
test_mypy.py:7: note: Revealed type is 'def (query: builtins.str, result: builtins.str)'
> mypy --disallow-untyped-decorators test_mypy.py
test_mypy.py:3: error: Untyped decorator makes function "test_raw" untyped
test_mypy.py:7: note: Revealed type is 'def (query: builtins.str, result: builtins.str)'
> pip list
Package            Version
------------------ -------
attrs              19.3.0
importlib-metadata 1.7.0
iniconfig          1.0.0
more-itertools     8.4.0
mypy               0.782
mypy-extensions    0.4.3
packaging          20.4
pip                20.1.1
pluggy             0.13.1
py                 1.9.0
pyparsing          2.4.7
pytest             6.0.1
setuptools         49.2.0
six                1.15.0
toml               0.10.1
typed-ast          1.4.1
typing-extensions  3.7.4.2
wheel              0.34.2
zipp               3.1.0
@Zac-HD Zac-HD added topic: typing type-annotation issue type: enhancement new feature or API change, should be merged into features branch labels Jul 31, 2020
@bluetech
Copy link
Member

This is a mypy bug. I proposed a fix here: python/mypy#9232.

I'm afraid there isn't a simple workaround for this in pytest. Hopefully the mypy fix will be merged and released, but until then I suggest turning off disallow-untyped-decorators (at least in your test modules) are adding type: ignore comments.

JukkaL pushed a commit to python/mypy that referenced this issue Jul 31, 2020
… overloads (#9232)

When --disallow-untyped-decorators is used, a callable-class decorator 
with a overloads on its __call__ implementation would incorrectly issue an 
"Untyped decorator makes function untyped" error, even when the overloads 
are typed properly. This has been reported in pytest, which does this: 
pytest-dev/pytest#7589.

This fixes the problem by expanding on a previous fix in this area, #5509.
pmav99 added a commit to pmav99/tbump that referenced this issue Sep 3, 2020
This is due to a mypy bug. It is only needed with pytest 6+ on python 3.7
(python 3.8 works fine) and it will probably be solved in a newer mypy
version

More info: pytest-dev/pytest#7589
pmav99 added a commit to pmav99/tbump that referenced this issue Sep 3, 2020
This is due to a mypy bug. It is only needed with pytest 6+ on python 3.7
(python 3.8 works fine) and it will probably be solved in a newer mypy
version

More info: pytest-dev/pytest#7589
zackw added a commit to zackw/infinitestimal that referenced this issue Aug 16, 2021
We need at least pytest 6.2.0, as well as a recent mypy, for the fix for
the spurious “error: Untyped decorator makes function "test_xxx" untyped”
diagnostic (pytest-dev/pytest#7589).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: typing type-annotation issue type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

No branches or pull requests

3 participants