Skip to content

Commit 884215e

Browse files
committed
Make backwards compatible
1 parent 68b9b58 commit 884215e

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/pyapp/app/argument_actions.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"KeyValueAction",
3333
"EnumValue",
3434
"EnumName",
35+
"EnumNameList",
3536
"AppendEnumValue",
3637
"AppendEnumName",
3738
)
@@ -283,7 +284,7 @@ def my_command(*, colours: Sequence[Colour]):
283284
> my_app m_command --colour red --colour blue
284285
[Colour.Red, Colour.Blue]
285286
286-
.. versionadded:: 4.8
287+
.. versionadded:: 4.9
287288
288289
"""
289290

@@ -312,6 +313,9 @@ def my_command(args: Namespace):
312313
> my_app m_command --colour Red --colour Blue
313314
[Colour.Red, Colour.Blue]
314315
315-
.. versionadded:: 4.8
316+
.. versionadded:: 4.9
316317
317318
"""
319+
320+
321+
EnumNameList = AppendEnumName

src/pyapp/app/arguments.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
from pyapp.compatability import async_run
2626
from pyapp.utils import cached_property
2727

28+
from .argument_actions import AppendEnumName
2829
from .argument_actions import EnumName
29-
from .argument_actions import EnumNameList
3030
from .argument_actions import KeyValueAction
3131

3232
__all__ = ("Handler", "argument", "CommandGroup", "Arg", "ArgumentType")
@@ -231,7 +231,7 @@ def _handle_generics( # pylint: disable=too-many-branches
231231
elif issubclass(origin, Sequence):
232232
args = type_.__args__
233233
if len(args) == 1 and issubclass(args[0], Enum):
234-
kwargs["action"] = EnumNameList
234+
kwargs["action"] = AppendEnumName
235235
elif positional:
236236
kwargs["nargs"] = "+"
237237
else:

tests/app/test_arguments_signatures.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from pyapp.app import CommandOptions
1414
from pyapp.app.argument_actions import AppendEnumName
1515
from pyapp.app.argument_actions import EnumName
16-
from pyapp.app.argument_actions import EnumNameList
1716
from pyapp.app.argument_actions import KeyValueAction
1817
from pyapp.app.argument_types import RegexType
1918
from pyapp.app.arguments import Arg
@@ -246,7 +245,7 @@ def func_sample_24(*, arg_1: re_type):
246245
return arg_1
247246

248247

249-
@expected_args(mock.call("--arg-1", type=Colour, action=EnumNameList))
248+
@expected_args(mock.call("--arg-1", type=Colour, action=AppendEnumName))
250249
@call_args("--arg-1", "Green", "--arg-1", "Red", expected=[Colour.Green, Colour.Red])
251250
def func_sample_25(*, arg_1: Sequence[Colour]):
252251
return arg_1

0 commit comments

Comments
 (0)