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

Revealed type of click decorators is Any #6156

Closed
SnoopJ opened this issue Oct 12, 2021 · 6 comments
Closed

Revealed type of click decorators is Any #6156

SnoopJ opened this issue Oct 12, 2021 · 6 comments

Comments

@SnoopJ
Copy link

SnoopJ commented Oct 12, 2021

NOTE: Appears to be caused by #5483. Issue does not occur against stubs prior to 7a9a107 (e.g. with types-click==0.1.12).

The stubs for click annotate the return type of many of the library's decorator factories as IdentityFunction (e.g. see argument stub, but the revealed type when running mypy is Any. See sample program below.

I'm not sure if this is indicative of an underlying bug in mypy or if there's something missing in the usage of IdentityFunction from typeshed that keeps it from resolving that helper. Insight from someone who is more familiar with the details would be appreciated.

Sample program

import click

reveal_type(click.argument("foo"))

@click.command()
@click.argument("foo")
def cli(foo: str) -> None:
    ...

reveal_type(cli)

Output

12:17 [snoopjedi@denton ~]
$ python3 -m mypy --strict repro.py 
repro.py:3: note: Revealed type is "Any"
repro.py:6: error: Untyped decorator makes function "cli" untyped
repro.py:10: note: Revealed type is "click.core.Command"
Found 1 error in 1 file (checked 1 source file)

Version information

  • Python: 3.8.10
  • mypy: 0.910
  • types-click: 7.1.6

NOTE: I am submitting this issue on behalf of a user who asked a question about it in #python on the Libera IRC network.

@JelleZijlstra
Copy link
Member

This is probably the same kind of issue as #5751.

@Akuli
Copy link
Collaborator

Akuli commented Oct 12, 2021

If you are using the latest click, you don't need types-click, and you should report any issues to click, not to typeshed. See #5423

@SnoopJ
Copy link
Author

SnoopJ commented Oct 12, 2021

If you are using the latest click, you don't need types-click, and you should report any issues to click, not to typeshed. See #5423

Thanks. The issue does not occur for me with click 8.0.3, but this is still a problem for users who are pinned against the older version(s).

Additional information: I have been told that pyright is able to do the right thing with this stub, which along with #5751 makes me think this issue is already being tracked.

Closing this issue, thanks for the info y'all.

@SamJoan
Copy link

SamJoan commented Nov 30, 2021

For what it's worth, I experienced this regression when migrating between development environments due to a pinned dependency which itself pinned click.

I'm going to completely redo my dependency management in this case because it just makes sense but definitely a regression imo, not sure if it will impact anything else.

@hauntsaninja
Copy link
Collaborator

The only other report we've had of this kind of problem is with types-retry.
I agree this is problematic and really tough for users to debug, it's something we're now much more aware of / I don't think we really anticipated when we shifted to modular typeshed. There's more discussion in #5751.

@SamJoan
Copy link

SamJoan commented Dec 7, 2021

Hi @hauntsaninja

In the end my issue does not seem to be related to this library. I thought it would be but I dug more into it and confirmed it is not. Letting you know so you don't worry about it too much hehe.

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

5 participants