Skip to content
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

Use of click.version_option results in "untyped decorator" error #5642

Closed
cjolowicz opened this issue Jun 15, 2021 · 4 comments
Closed

Use of click.version_option results in "untyped decorator" error #5642

cjolowicz opened this issue Jun 15, 2021 · 4 comments

Comments

@cjolowicz
Copy link

cjolowicz commented Jun 15, 2021

Using mypy 0.902 and types-click 7.1.1, @click.version_option is considered untyped, resulting in this error:

Untyped decorator makes function "main" untyped

Steps to reproduce:

repro.py

import click


@click.command()
@click.version_option()
def main() -> None:
    """Main."""


if __name__ == "__main__":
    main()

repro.sh

#!/bin/bash

virtualenv -p 3.9 venv
. venv/bin/activate
pip install mypy types-click
mypy --strict --pretty repro.py

Actual output:

repro.py:5: error: Untyped decorator makes function "main" untyped
    @click.version_option()
     ^
Found 1 error in 1 file (checked 1 source file)

Expected output:

Success: no issues found in 1 source file

Environment:

$ venv/bin/pip freeze
mypy==0.902
mypy-extensions==0.4.3
toml==0.10.2
types-click==7.1.1
typing-extensions==3.10.0.0
@ska-kialo
Copy link
Contributor

Having the same issue with click.option and click.argument.

@srittau
Copy link
Collaborator

srittau commented Jun 16, 2021

Please note that starting with click 8, click ships a py.typed file and typeshed's stubs are ignored. In fact, when trying the original example with only types-click installed, but not click, it type checks just fine.

@srittau srittau closed this as completed Jun 16, 2021
@cjolowicz
Copy link
Author

@srittau Thanks for clarifying this.

I guess the pitfall here is:

  1. upgrade mypy >= 0.900
  2. install types-click because of the mypy warning
  3. upgrade click >= 8.0
  4. mypy complains about "untyped decorator"

Assuming that click is installed, removing types-click also solves this.

cjolowicz added a commit to cjolowicz/cookiecutter-hypermodern-python-instance that referenced this issue Jun 16, 2021
click >= 8.0 ships with py.typed, so types-click is not required.

Installing types-click with click >= 8.0 leads to a mypy error:

- python/typeshed#5642
cjolowicz added a commit to cjolowicz/cookiecutter-hypermodern-python that referenced this issue Jun 16, 2021
click >= 8.0 ships with py.typed, so types-click is not required.

Installing types-click with click >= 8.0 leads to a mypy error:

- python/typeshed#5642
@srittau
Copy link
Collaborator

srittau commented Jun 16, 2021

Weird that uninstalling types-click changes anything. Anyway, I have opened python/mypy#10652 to remove the suggestion to install these stubs.

cjolowicz added a commit to cjolowicz/cookiecutter-hypermodern-python that referenced this issue Jun 16, 2021
* Remove types-click from Nox session for mypy

click >= 8.0 ships with py.typed, so types-click is not required.

Installing types-click with click >= 8.0 leads to a mypy error:

- python/typeshed#5642

* Remove unused `type: ignore` on `@click.version_option`
cjolowicz added a commit to cjolowicz/cookiecutter-hypermodern-python-instance that referenced this issue Jun 16, 2021
* Remove types-click from Nox session for mypy

click >= 8.0 ships with py.typed, so types-click is not required.

Installing types-click with click >= 8.0 leads to a mypy error:

- python/typeshed#5642

* Remove unused `type: ignore` on `@click.version_option`

Original-Commit: cjolowicz/cookiecutter-hypermodern-python@a901928
JelleZijlstra pushed a commit to python/mypy that referenced this issue Jun 16, 2021
The pallets libraries are now bundled with a `py.typed` file. Suggesting to install these stubs only leads to confusion. See python/typeshed#5423 and python/typeshed#5642 for context.
JukkaL pushed a commit to python/mypy that referenced this issue Jun 21, 2021
The pallets libraries are now bundled with a `py.typed` file. Suggesting to install these stubs only leads to confusion. See python/typeshed#5423 and python/typeshed#5642 for context.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants