From e0033315510510acdba14e880a361ccca091fb4b Mon Sep 17 00:00:00 2001 From: Matthew Martin Date: Wed, 5 Jan 2022 21:16:43 -0600 Subject: fix ParamType.to_info_dict() with no name --- src/click/types.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/click/types.py b/src/click/types.py index aab0656..3a78a3a 100644 --- a/src/click/types.py +++ b/src/click/types.py @@ -63,7 +63,14 @@ class ParamType: # The class name without the "ParamType" suffix. param_type = type(self).__name__.partition("ParamType")[0] param_type = param_type.partition("ParameterType")[0] - return {"param_type": param_type, "name": self.name} + + # Custom subclasses might not remember to set a name. + if hasattr(self, "name"): + name = self.name + else: + name = param_type + + return {"param_type": param_type, "name": name} def __call__( self, -- cgit v1.2.1