Skip to content

Commit 31c54f3

Browse files
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
1 parent 5a8a715 commit 31c54f3

File tree

4 files changed

+33
-30
lines changed

4 files changed

+33
-30
lines changed

tests/test_ambiguous_params.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ def test_forbid_default_value_in_annotated_argument():
2929
# This test case only works with `typer.Argument`. `typer.Option` uses positionals
3030
# for param_decls too.
3131
@app.command()
32-
def cmd(my_param: Annotated[str, typer.Argument("foo")]):
33-
... # pragma: no cover
32+
def cmd(my_param: Annotated[str, typer.Argument("foo")]): ... # pragma: no cover
3433

3534
with pytest.raises(AnnotatedParamWithDefaultValueError) as excinfo:
3635
runner.invoke(app)
@@ -64,8 +63,7 @@ def test_forbid_annotated_param_and_default_param(param, param_info_type):
6463
app = typer.Typer()
6564

6665
@app.command()
67-
def cmd(my_param: Annotated[str, param()] = param("foo")):
68-
... # pragma: no cover
66+
def cmd(my_param: Annotated[str, param()] = param("foo")): ... # pragma: no cover
6967

7068
with pytest.raises(MixedAnnotatedAndDefaultStyleError) as excinfo:
7169
runner.invoke(app)
@@ -81,8 +79,9 @@ def test_forbid_multiple_typer_params_in_annotated():
8179
app = typer.Typer()
8280

8381
@app.command()
84-
def cmd(my_param: Annotated[str, typer.Argument(), typer.Argument()]):
85-
... # pragma: no cover
82+
def cmd(
83+
my_param: Annotated[str, typer.Argument(), typer.Argument()]
84+
): ... # pragma: no cover
8685

8786
with pytest.raises(MultipleTyperAnnotationsError) as excinfo:
8887
runner.invoke(app)
@@ -117,8 +116,9 @@ def make_string():
117116
app = typer.Typer()
118117

119118
@app.command()
120-
def cmd(my_param: Annotated[str, param(default_factory=make_string)] = "hello"):
121-
... # pragma: no cover
119+
def cmd(
120+
my_param: Annotated[str, param(default_factory=make_string)] = "hello"
121+
): ... # pragma: no cover
122122

123123
with pytest.raises(DefaultFactoryAndDefaultValueError) as excinfo:
124124
runner.invoke(app)
@@ -165,8 +165,9 @@ def make_string():
165165
app = typer.Typer()
166166

167167
@app.command()
168-
def cmd(my_param: str = param("hi", default_factory=make_string)):
169-
... # pragma: no cover
168+
def cmd(
169+
my_param: str = param("hi", default_factory=make_string)
170+
): ... # pragma: no cover
170171

171172
with pytest.raises(DefaultFactoryAndDefaultValueError) as excinfo:
172173
runner.invoke(app)

typer/_typing.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,11 @@ def convert_generics(tp: Type[Any]) -> Type[Any]:
237237

238238
# recursively replace `str` instances inside of `GenericAlias` with `ForwardRef(arg)`
239239
converted = tuple(
240-
ForwardRef(arg)
241-
if isinstance(arg, str) and isinstance(tp, TypingGenericAlias)
242-
else convert_generics(arg)
240+
(
241+
ForwardRef(arg)
242+
if isinstance(arg, str) and isinstance(tp, TypingGenericAlias)
243+
else convert_generics(arg)
244+
)
243245
for arg in args
244246
)
245247

typer/params.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ def Option(
6868
path_type: Union[None, Type[str], Type[bytes]] = None,
6969
# Rich settings
7070
rich_help_panel: Union[str, None] = None,
71-
) -> Any:
72-
...
71+
) -> Any: ...
7372

7473

7574
# Overload for Option created with custom type 'click_type'
@@ -132,8 +131,7 @@ def Option(
132131
path_type: Union[None, Type[str], Type[bytes]] = None,
133132
# Rich settings
134133
rich_help_panel: Union[str, None] = None,
135-
) -> Any:
136-
...
134+
) -> Any: ...
137135

138136

139137
def Option(
@@ -305,8 +303,7 @@ def Argument(
305303
path_type: Union[None, Type[str], Type[bytes]] = None,
306304
# Rich settings
307305
rich_help_panel: Union[str, None] = None,
308-
) -> Any:
309-
...
306+
) -> Any: ...
310307

311308

312309
# Overload for Argument created with custom type 'click_type'
@@ -361,8 +358,7 @@ def Argument(
361358
path_type: Union[None, Type[str], Type[bytes]] = None,
362359
# Rich settings
363360
rich_help_panel: Union[str, None] = None,
364-
) -> Any:
365-
...
361+
) -> Any: ...
366362

367363

368364
def Argument(

typer/rich_utils.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@
6868
STYLE_ABORTED = "red"
6969
_TERMINAL_WIDTH = getenv("TERMINAL_WIDTH")
7070
MAX_WIDTH = int(_TERMINAL_WIDTH) if _TERMINAL_WIDTH else None
71-
COLOR_SYSTEM: Optional[
72-
Literal["auto", "standard", "256", "truecolor", "windows"]
73-
] = "auto" # Set to None to disable colors
71+
COLOR_SYSTEM: Optional[Literal["auto", "standard", "256", "truecolor", "windows"]] = (
72+
"auto" # Set to None to disable colors
73+
)
7474
_TYPER_FORCE_DISABLE_TERMINAL = getenv("_TYPER_FORCE_DISABLE_TERMINAL")
7575
FORCE_TERMINAL = (
7676
True
@@ -206,9 +206,11 @@ def _get_help_text(
206206
if markup_mode != MARKUP_MODE_RICH:
207207
# Remove single linebreaks
208208
remaining_paragraphs = [
209-
x.replace("\n", " ").strip()
210-
if not x.startswith("\b")
211-
else "{}\n".format(x.strip("\b\n"))
209+
(
210+
x.replace("\n", " ").strip()
211+
if not x.startswith("\b")
212+
else "{}\n".format(x.strip("\b\n"))
213+
)
212214
for x in remaining_paragraphs
213215
]
214216
# Join back together
@@ -266,9 +268,11 @@ def _get_parameter_help(
266268
# Remove single linebreaks
267269
if markup_mode != MARKUP_MODE_MARKDOWN:
268270
paragraphs = [
269-
x.replace("\n", " ").strip()
270-
if not x.startswith("\b")
271-
else "{}\n".format(x.strip("\b\n"))
271+
(
272+
x.replace("\n", " ").strip()
273+
if not x.startswith("\b")
274+
else "{}\n".format(x.strip("\b\n"))
275+
)
272276
for x in paragraphs
273277
]
274278
items.append(

0 commit comments

Comments
 (0)