The documentation and the type annotations don't quite match for click.BadParameter, specifically for the param_hint argument. The documentation says:
If it is a string it's used as such, if it's a list then each item is quoted and separated.
But the type annotation says:
param_hint: str | None = None
To reproduce, create code like:
raise click.BadParameter("FOOBIE BLETCH", param_hint=["HACKEM", "MUCHE"])
then run mypy on said code.
Expected: mypy gives no error
Actual behaviour: mypy says:
foo.py:2: error: Argument "param_hint" to "BadParameter" has incompatible type "list[str]"; expected "str | None" [arg-type]
Easy to fix, just need to update the type hint for param_hint to the one already used in _join_param_hints:
cabc.Sequence[str] | str | None
Environment:
- Python version: 3.11.2
- Click version: 8.1.7
The documentation and the type annotations don't quite match for
click.BadParameter, specifically for theparam_hintargument. The documentation says:But the type annotation says:
To reproduce, create code like:
then run
mypyon said code.Expected:
mypygives no errorActual behaviour:
mypysays:Easy to fix, just need to update the type hint for
param_hintto the one already used in_join_param_hints:Environment: