Skip to content

0.30.X is breaking console scripts by moving options to positional arguments #206

Closed
@valentin-feron

Description

@valentin-feron

My CI pipelines broke after 0.30.X release. The options of my python scripts are now positional arguments.

output of the helper of one of my tool with argh 0.29.3:

positional arguments:
  commit_message        -

options:
  -h, --help            show this help message and exit
  -w WORK_TREE, --work-tree WORK_TREE
                        '.'
  -g GIT_DIR, --git-dir GIT_DIR
                        -
  -a, --auto-choose-default-action
                        False
  --bypass-docstring-validation
                        False
  --bypass-tests        False
  --bypass-code-formatting
                        False
  -v, --verbose         False

Output of the same helper with argh 0.30.1:

positional arguments:
  commit-message        -
  work-tree             '.'
  git-dir               -
  auto-choose-default-action
                        False
  bypass-docstring-validation
                        False
  bypass-tests          False
  bypass-code-formatting
                        False
  verbose               False

options:
  -h, --help            show this help message and exit

Here is the signature of the python function:

def check_in(
    commit_message: str,
    work_tree='.',
    git_dir=None,
    auto_choose_default_action=False,
    bypass_docstring_validation=False,
    bypass_tests=False,
    bypass_code_formatting=False,
    verbose=False,
):

After doing the following, I get the options back:

def check_in(
    commit_message: str,
    *,
    work_tree='.',
    git_dir=None,
    auto_choose_default_action=False,
    bypass_docstring_validation=False,
    bypass_tests=False,
    bypass_code_formatting=False,
    verbose=False,
):

It is not a bug, since a choice has been made to change how "positional or keyword" args are interpreted, switching from options (except for the first arg) to positional arguments. But it will break a lot of user's commands, as it did for me.

Maybe adding a warning when wrapping a function that contains "positional or keyword" args would be enough (it would have made me save some precious time actually), encouraging the user to use "positional only" and "keyword only" args.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions