You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is incorrect code, but a very reasonable mistake to make.
Currently, code like this emits a rather cryptic error like so:
Traceback (most recent call last):
File "cmd.py", line 3, in <module>
def cmd(number):
File ".../lib/python3.8/site-packages/click/decorators.py", line 308, in decorator
_param_memo(f, OptionClass(param_decls, **option_attrs))
File ".../lib/python3.8/site-packages/click/core.py", line 2495, in __init__
super().__init__(param_decls, type=type, multiple=multiple, **attrs)
File ".../lib/python3.8/site-packages/click/core.py", line 2075, in __init__
self.type = types.convert_type(type, default)
File ".../lib/python3.8/site-packages/click/types.py", line 1040, in convert_type
return FuncParamType(ty)
File ".../lib/python3.8/site-packages/click/types.py", line 165, in __init__
self.name = func.__name__
File ".../lib/python3.8/typing.py", line 760, in __getattr__
raise AttributeError(attr)
AttributeError: __name__
This is a fairly cryptic error, and it would be better to intercept this and raise a more descriptive error to explain the problem.
The text was updated successfully, but these errors were encountered:
@davidism this is not really about type checking. This is about emitting a better error message in a case of very reasonable incorrect usage of the library. Could you look at my example again and reconsider?
Click should raise a clear error when a user tries to pass a generic type such as
Optional[int]
as the type parameter to an option, for example:This is incorrect code, but a very reasonable mistake to make.
Currently, code like this emits a rather cryptic error like so:
This is a fairly cryptic error, and it would be better to intercept this and raise a more descriptive error to explain the problem.
The text was updated successfully, but these errors were encountered: