Skip to content

Question: Can no-cover "cover" the rest of the function? #1741

@stdedos

Description

@stdedos

Is your feature request related to a problem? Please describe.

I have the end of the main() function like so:

    ...

    if args.command == Commands.CMD.value:
        return cmd_handler(j, args)
    
    print(f"Either command '{args.command}' was not handled, or the end of the world is coming!\n", file=sys.stderr)
    parser.print_help(file=sys.stderr)

    return os.EX_USAGE

I'd like to ignore it with a no-cover.

Basically, the rest of the function would be hard to hit (somehow argparse does not "match" command with its function, or dev forgets to return cmd_handler().

I'd like to avoid the if return else pattern since, on top of that, I agree with the https://pylint.pycqa.org/en/latest/user_guide/messages/refactor/no-else-return.html check aesthetically

Any solutions I missed?

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions