Skip to content

Commit be93bf0

Browse files
committed
Auto-format
1 parent 169c42c commit be93bf0

File tree

4 files changed

+40
-29
lines changed

4 files changed

+40
-29
lines changed

radicli/cli.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from .util import ConverterType, ConvertersType, ErrorHandlersType, StaticCommand
1717
from .util import StaticData, DEFAULT_CONVERTERS, DEFAULT_PLACEHOLDER
1818

19-
2019
_CallableT = TypeVar("_CallableT", bound=Callable)
2120
DEFAULT_EXTRA_KEY = "_extra"
2221

radicli/tests/test_cli.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
from typing import List, Iterator, Optional, Literal, TypeVar, Generic, Type, Union, cast
1+
from typing import (
2+
List,
3+
Iterator,
4+
Optional,
5+
Literal,
6+
TypeVar,
7+
Generic,
8+
Type,
9+
Union,
10+
cast,
11+
)
212
from enum import Enum
313
from dataclasses import dataclass
414
import pytest
@@ -137,8 +147,7 @@ def test_cli_required():
137147
cli = Radicli()
138148

139149
@cli.command("test", a=Arg(), b=Arg("--b"), c=Arg("--c"), d=Arg("--d"))
140-
def test(a: str, b: str, c: int, d: int = 0):
141-
...
150+
def test(a: str, b: str, c: int, d: int = 0): ...
142151

143152
with pytest.raises(CliParserError) as err:
144153
cli.run(["", "test", "hello", "--c", "1"])
@@ -256,8 +265,7 @@ def converter(value):
256265
raise TypeError(error_msg)
257266

258267
@cli.command("test", a=Arg("--a", converter=converter))
259-
def test(a: str):
260-
...
268+
def test(a: str): ...
261269

262270
with pytest.raises(CliParserError, match=error_msg):
263271
cli.run(["", "test", "--a", "hello"])
@@ -306,8 +314,7 @@ def test(a: str, b: List[str], c: CustomType):
306314
_KindT = TypeVar("_KindT", bound=Union[str, int, float, Path])
307315

308316

309-
class CustomGeneric(Generic[_KindT]):
310-
...
317+
class CustomGeneric(Generic[_KindT]): ...
311318

312319

313320
def test_cli_converters_generics():
@@ -328,8 +335,7 @@ def test(a: CustomGeneric[str]):
328335
def test_cli_converters_generics_multiple():
329336
_KindT = TypeVar("_KindT")
330337

331-
class CustomGeneric(Generic[_KindT]):
332-
...
338+
class CustomGeneric(Generic[_KindT]): ...
333339

334340
converters = {
335341
CustomGeneric: lambda value: f"generic: {value}",
@@ -917,8 +923,8 @@ def convert_generic(value: str) -> str:
917923
def test_static_default_serialization():
918924
cli = Radicli(prog="test")
919925

920-
@cli.command("test", a=Arg("--a", short='-a'))
921-
def _(a: List[str]=[]):
926+
@cli.command("test", a=Arg("--a", short="-a"))
927+
def _(a: List[str] = []):
922928
"""Hello"""
923929

924930
with make_tempdir() as dir_path:
@@ -1012,8 +1018,7 @@ def test_cli_booleans():
10121018
b=Arg("--b"),
10131019
c=Arg("--c"),
10141020
)
1015-
def test(a: bool, b: bool = False, c: bool = True):
1016-
...
1021+
def test(a: bool, b: bool = False, c: bool = True): ...
10171022

10181023
args = ["--a", "--b", "--c"]
10191024
parsed = cli.parse(args, cli.commands["test"])

radicli/tests/test_util.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
_KindT = TypeVar("_KindT", bound=Union[str, int, float, Path])
1111

1212

13-
class CustomGeneric(Generic[_KindT]):
14-
...
13+
class CustomGeneric(Generic[_KindT]): ...
1514

1615

1716
@pytest.mark.parametrize(
@@ -62,12 +61,14 @@ def test_get_list_converter(item_type, value, expected):
6261
converter = get_list_converter(item_type)
6362
assert converter(value) == expected
6463

64+
6565
def test_get_arg_string_type():
6666
arg_info = Arg()
6767
result = get_arg("test_param", arg_info, "str")
6868
assert result.type is str
6969

70+
7071
def test_get_arg_regular_type():
7172
arg_info = Arg()
7273
result = get_arg("test_param", arg_info, int)
73-
assert result.type is int
74+
assert result.type is int

radicli/util.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,16 @@ def to_static_json(self) -> StaticArg:
218218
"option": self.arg.option,
219219
"short": self.arg.short,
220220
"orig_help": self.arg.help,
221-
"default": str(self.default)
222-
if self.default not in (False, None)
223-
else self.default,
221+
"default": (
222+
str(self.default) if self.default not in (False, None) else self.default
223+
),
224224
"help": self.help,
225225
"action": str(self.action) if self.action else None,
226-
"choices": list(c.value if isinstance(c, Enum) else c for c in self.choices)
227-
if self.choices
228-
else None,
226+
"choices": (
227+
list(c.value if isinstance(c, Enum) else c for c in self.choices)
228+
if self.choices
229+
else None
230+
),
229231
"has_converter": self.has_converter,
230232
"type": stringify_type(self.type),
231233
"orig_type": stringify_type(self.orig_type),
@@ -243,11 +245,15 @@ def from_static_json(
243245
arg=Arg(data["option"], data["short"], help=data["orig_help"]),
244246
type=deserialize_type(data, converters),
245247
orig_type=data["orig_type"],
246-
default=[]
247-
if data['action'] == 'append'
248-
else DEFAULT_PLACEHOLDER
249-
if data["default"] == DEFAULT_PLACEHOLDER
250-
else data["default"],
248+
default=(
249+
[]
250+
if data["action"] == "append"
251+
else (
252+
DEFAULT_PLACEHOLDER
253+
if data["default"] == DEFAULT_PLACEHOLDER
254+
else data["default"]
255+
)
256+
),
251257
help=data["help"],
252258
action=data["action"],
253259
choices=data["choices"],
@@ -467,7 +473,7 @@ def format_arg_help(text: Optional[str], max_width: int = 70) -> str:
467473

468474

469475
def expand_error_subclasses(
470-
errors: Dict[Type[Exception], ErrorHandlerType]
476+
errors: Dict[Type[Exception], ErrorHandlerType],
471477
) -> Dict[Type[Exception], ErrorHandlerType]:
472478
"""Map subclasses of errors to their parent's handler."""
473479
output = {}

0 commit comments

Comments
 (0)