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

command and group decorators are untyped on strict #2255

Closed
Jonxslays opened this issue Apr 22, 2022 · 4 comments · Fixed by #2256
Closed

command and group decorators are untyped on strict #2255

Jonxslays opened this issue Apr 22, 2022 · 4 comments · Fixed by #2256
Milestone

Comments

@Jonxslays
Copy link
Contributor

Summary:
The click.command and click.group decorators are currently untyped and cause typing errors on strict pyright. (I haven't tested with mypy).

Replication:

  • Install click
  • Install pyright
# pyproject.toml

[tool.pyright]
typeCheckingMode = "strict"
# main.py

import click

@click.command()
def cli_main() -> None:
    ...

@click.group()
def cli_group() -> None:
    ...

These decorators are both unknown due to the use of typing.Callable with no generics. PR incoming.

Environment:

  • Python version: 3.10.4
  • Click version: 8.1.2
@davidism davidism added this to the 8.1.3 milestone Apr 24, 2022
@davidism davidism linked a pull request Apr 24, 2022 that will close this issue
6 tasks
@davidism
Copy link
Member

From the typing docs: https://docs.python.org/3/library/typing.html#typing.Callable

A plain Callable is equivalent to Callable[..., Any], and in turn to collections.abc.Callable.

This should be reported to pyright.

@Jonxslays
Copy link
Contributor Author

Interesting, I will open a discussion there. Thanks!

@davidism
Copy link
Member

davidism commented Apr 26, 2022

Fix is fine, I merged it. But pyright shouldn't be reporting it in the first place. Please leave a link here to the issue.

@Jonxslays
Copy link
Contributor Author

Opened microsoft/pyright#3386 regarding this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants