Skip to content
Myr

fix(typing): Using correct typing for `param_hint`

Before adoption: this commit came in with the history the project adopted, so no landing records it.

The typing of `param_hint` between `BadParameter`, `MissingParameter` and `_join_param_hints` was different. The firsts only allowed for a `str` where the later also accept a sequence of `str`. Fixes https://github.com/pallets/click/issues/2777

authored by Firelight Flagboy · committed by Firelight Flagboy · parent 565f36d · Browse files · 2 files+6 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+6 added−3 removed

  • other:+6 added−3 removed

2 files+6 added−3 removed

modified:src/click/exceptions.py+3 added-3 removed
113 unmodified lines
114 self,115 message: str,116 ctx: Context | None = None,117 param: Parameter | None = None,118 param_hint: str | None = None,118 param_hint: cabc.Sequence[str] | str | None = None,119 ) -> None:120 super().__init__(message, ctx)121 self.param = param122 self.param_hint = param_hint
27 unmodified lines
150 self,151 message: str | None = None,152 ctx: Context | None = None,153 param: Parameter | None = None,154 param_hint: str | None = None,154 param_hint: cabc.Sequence[str] | str | None = None,155 param_type: str | None = None,156 ) -> None:157 super().__init__(message or "", ctx, param, param_hint)158 self.param_type = param_type159160 def format_message(self) -> str:161 if self.param_hint is not None:162 param_hint: str | None = self.param_hint162 param_hint: cabc.Sequence[str] | str | None = self.param_hint163 elif self.param is not None:164 param_hint = self.param.get_error_hint(self.ctx) # type: ignore165 else:166 param_hint = None
142 unmodified lines
modified:CHANGES.rst+3 added
6 unmodified lines
78- Fix reconciliation of `default`, `flag_value` and `type` parameters for9 flag options, as well as parsing and normalization of environment variables.10 :issue:`2952` :pr:`2956`11- Fix typing issue in ``BadParameter`` and ``MissingParameter`` exceptions for the12 parameter ``param_hint`` that did not allow for a sequence of string where the13 underlying functino ``_join_param_hints`` allows for it. :issue:`2777` :pr:`2990`1415Version 8.2.116-------------17
1242 unmodified lines