pythonpylint

W0622: Redefining built-in 'help' (redefined-builtin)


I have this method that causes a pylint issue:

def add_ssh_config_path(self,
                        help="Enter ssh-config path for ssh connection to the host.",
                        required=False, metavar="<SSH_CONFIG_PATH>"):
    self._parser.add_argument("--ssh-config-path", metavar=metavar,
                              required=required, help=help, type=str)
    return self

The issue is:

W0622: Redefining built-in 'help' (redefined-builtin)

I am not able to understand the issue. Why is help a built-in in the context of a method definition? How do I get around this issue?


Solution

  • The issue occurs because help is a built-in function, and using it as a parameter name shadows the built-in, triggering pylint's W0622 warning. You can fix it by renaming the parameter, then you'll avoid the conflict:

    def add_ssh_config_path(self,
                            help_text="Enter ssh-config path for ssh connection to the host.",
                            required=False, metavar="<SSH_CONFIG_PATH>"):
        self._parser.add_argument("--ssh-config-path", metavar=metavar,
                                  required=required, help=help_text, type=str)
        return self