Skip to content

Commit 6aac395

Browse files
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
1 parent f107389 commit 6aac395

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
@@ -67,8 +67,7 @@ def Option(
6767
path_type: Union[None, Type[str], Type[bytes]] = None,
6868
# Rich settings
6969
rich_help_panel: Union[str, None] = None,
70-
) -> Any:
71-
...
70+
) -> Any: ...
7271

7372

7473
@overload
@@ -130,8 +129,7 @@ def Option(
130129
path_type: Union[None, Type[str], Type[bytes]] = None,
131130
# Rich settings
132131
rich_help_panel: Union[str, None] = None,
133-
) -> Any:
134-
...
132+
) -> Any: ...
135133

136134

137135
def Option(
@@ -301,8 +299,7 @@ def Argument(
301299
path_type: Union[None, Type[str], Type[bytes]] = None,
302300
# Rich settings
303301
rich_help_panel: Union[str, None] = None,
304-
) -> Any:
305-
...
302+
) -> Any: ...
306303

307304

308305
@overload
@@ -355,8 +352,7 @@ def Argument(
355352
path_type: Union[None, Type[str], Type[bytes]] = None,
356353
# Rich settings
357354
rich_help_panel: Union[str, None] = None,
358-
) -> Any:
359-
...
355+
) -> Any: ...
360356

361357

362358
def Argument(

typer/rich_utils.py

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

0 commit comments

Comments
 (0)