Skip to content

ParamType missing name errors on to_info_dict #2168

@phy1729

Description

@phy1729

When calling to_info_dict on a ParamType instance which doesn't have a name attribute, an exception is raised. While this is a bug in the downstream code, only to_info_dict is affected, so the bug often goes unnoticed.

class TestType(click.ParamType):
    pass

TestType().to_info_dict()
>       return {"param_type": param_type, "name": self.name}
E       AttributeError: 'TestType' object has no attribute 'name'

src/click/types.py:66: AttributeError

It would be nice to have some sort of reasonable fallback. I've put coded such possibility at main...phy1729:fix-ParamType-no-name . I also fixed where the docs neglected to specify name in an example.

Environment:

  • Python version: Python 3.9.9
  • Click version: 8.0.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions