Skip to content

Commit c8bb936

Browse files
committed
💚 fix tests locally
1 parent 1b02105 commit c8bb936

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

tests/test_parameter_help.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88
from typing_extensions import Doc
99

1010

11-
@pytest.fixture
12-
def runner():
13-
return CliRunner()
14-
15-
1611
@pytest.mark.parametrize(
1712
"doc,parameter,expected",
1813
[
@@ -41,12 +36,13 @@ def runner():
4136
),
4237
],
4338
)
44-
def test_doc_help(runner, doc, parameter, expected):
39+
def test_doc_help(doc, parameter, expected):
4540
app = typer.Typer()
4641

4742
@app.command()
4843
def main(arg: Annotated[str, doc, parameter]):
4944
print(f"Hello {arg}")
5045

46+
runner = CliRunner()
5147
result = runner.invoke(app, ["--help"])
5248
assert expected in result.stdout

typer/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,12 +827,12 @@ def get_click_param(
827827
for annotation in param.other_annotations
828828
if isinstance(annotation, Doc)
829829
]
830+
if len(doc_annotations) > 1:
831+
raise MultipleDocAnnotationsError(param.name)
830832
if len(doc_annotations) == 1:
831833
doc_help = doc_annotations[0].documentation if doc_annotations else None
832834
if not getattr(parameter_info, "help", None):
833835
parameter_info.help = doc_help
834-
if len(doc_annotations) > 1:
835-
raise MultipleDocAnnotationsError(param.name)
836836
annotation: Any
837837
if param.annotation is not param.empty:
838838
annotation = param.annotation

typer/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def get_params_from_function(func: Callable[..., Any]) -> Dict[str, ParamMeta]:
144144
)
145145
if len(typer_annotations) > 1:
146146
raise MultipleTyperAnnotationsError(param.name)
147+
147148
default = param.default
148149
if typer_annotations:
149150
# It's something like `my_param: Annotated[str, Argument()]`
@@ -157,6 +158,8 @@ def get_params_from_function(func: Callable[..., Any]) -> Dict[str, ParamMeta]:
157158
default_param_type=type(param.default),
158159
)
159160

161+
parameter_info = copy(parameter_info)
162+
160163
# When used as a default, `Option` takes a default value and option names
161164
# as positional arguments:
162165
# `Option(some_value, "--some-argument", "-s")`

0 commit comments

Comments
 (0)