Click: Error when running --help

Created on 21 Aug 2015  路  6Comments  路  Source: pallets/click

When running the command with the --help option:

  File "/usr/lib/python2.7/site-packages/click-4.0-py2.7.egg/click/core.py", line 1222, in make_metavar
    metavar = self.type.name.upper()
AttributeError: 'NoneType' object has no attribute 'upper'

All of the attributes have help defined.
Cheers

Most helpful comment

This is super old, but for all people coming here with the same problem:

In my case it was caused by using a custom click.ParamType which did not specify the name attribute. This is required to print the help text.

Example:

class MyType(click.ParamType):

    name = "name of your custom type"  # without this, I get the error above

    def convert(self, value, param, ctx):
        ...

All 6 comments

Please update your Click and provide an example that fails.

On 21 August 2015 04:38:25 CEST, Sebastian Oliva [email protected] wrote:

When running the command with the --help option:

"/usr/lib/python2.7/site-packages/click-4.0-py2.7.egg/click/core.py",
line 1222, in make_metavar
   metavar = self.type.name.upper()
AttributeError: 'NoneType' object has no attribute 'upper'

All of the attributes have help defined.
Cheers


Reply to this email directly or view it on GitHub:
https://github.com/mitsuhiko/click/issues/411

Sent from my phone. Please excuse my brevity.

Closing this since the author didn't provide any information on how to reproduce this.

This is super old, but for all people coming here with the same problem:

In my case it was caused by using a custom click.ParamType which did not specify the name attribute. This is required to print the help text.

Example:

class MyType(click.ParamType):

    name = "name of your custom type"  # without this, I get the error above

    def convert(self, value, param, ctx):
        ...

Thanks so much to @dmo60! I had the same problem and adding the name attribute in custom parameter type fixed it. By the way: In the documentation (section Implementing Custom Types) it says that the name attribute is optional - apparently it is not :-)

@rotkehlxen Would you be interested in doing a documentation PR for this?

@jcrotts What exactly wound that entail? sorry for the super late response ...

Was this page helpful?
0 / 5 - 0 ratings