Skip to content

[with_annotated] Using ArgumentBlock does not works with groups #1714

Description

@neoniobium

Description

ArgumentBlock typed arguments used with with_annotated do not work well with argument groups.

@dataclass
class Block(ArgumentBlock):
    A: ...
    B: ...


class App(Cmd):
    @with_annotated(groups=(Group("Block", ...), ...))
    def do_with_block(self, block_argument: Block) -> None:
        ...

Expected Behavior

The argument group should be created, and all arguments defined in Block should be listed in it (see the help message).

Actual Behavior

An argument group is created, but it does not list any arguments. Defining Group("A", "B", ...) is rejected and causes an error.

Possible Solution

I see at least three possible approaches:

  1. List all arguments defined in the ArgumentBlock in the corresponding argument groups when using the block to create the group.
  2. Allow arguments defined in the ArgumentBlock to be referenced when defining argument groups.
  3. Add syntax to define default argument groups inside the ArgumentBlock.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions