Skip to content

Fix TypeVar for decorators that handle Commands#2155

Merged
davidism merged 1 commit intopallets:8.0.xfrom
euresti:patch-1
Dec 28, 2021
Merged

Fix TypeVar for decorators that handle Commands#2155
davidism merged 1 commit intopallets:8.0.xfrom
euresti:patch-1

Conversation

@euresti
Copy link
Contributor

@euresti euresti commented Dec 17, 2021

The old type var would throw away the types of Callables.

import click

@click.option("--name", prompt="Your name", help="The person to greet.")
def hello(name: str) -> None:
    ...

reveal_type(hello)   #  note: Revealed type is 'def (*Any, **Any) -> Any'

With this small adjustment mypy now knows that it's a 'def (name: builtins.str)'

Checklist:

  • Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • Add or update relevant docs, in the docs folder and in code.
  • Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • Add .. versionchanged:: entries in any relevant code docs.
  • Run pre-commit hooks and fix any issues.
  • Run pytest and tox, no tests failed.

@davidism davidism changed the base branch from main to 8.0.x December 27, 2021 01:27
The old type var would throw away the types of Callables.

```
import click

@click.option("--name", prompt="Your name", help="The person to greet.")
def hello(name: str) -> None:
    ...

reveal_type(hello)   #  note: Revealed type is 'def (*Any, **Any) -> Any'
```

With this small adjustment mypy now knows that it's a `'def (name: builtins.str)'`
@davidism davidism added this to the 8.0.4 milestone Dec 28, 2021
@davidism davidism merged commit 08a825d into pallets:8.0.x Dec 28, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 12, 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 this pull request may close these issues.

2 participants