Skip to content
Myr

Catch a common mistake with passing uninstanciated parameter types.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 438b945 · Browse files · 2 files+10 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+10 added−1 removed

  • other:+10 added−1 removed

2 files+10 added−1 removed

modified:click/types.py+9 added
397 unmodified lines
398 if ty is float:399 return FLOAT400 if guessed_type:401 return STRING402403 # Catch a common mistake404 if __debug__:405 try:406 if issubclass(ty, ParamType):407 raise AssertionError('Attempted to use an uninstanciated '408 'parameter type (%s).' % ty)409 except TypeError:410 pass411 return FuncParamType(ty)412413414#: A unicode string parameter type which is the implicit default. This
17 unmodified lines
modified:examples/validation/validation.py+1 added-1 removed
25 unmodified lines
26@click.command()27@click.option('--count', default=2, callback=validate_count,28 help='A positive even number.')29@click.option('--foo', help='A mysterious parameter.')30@click.option('--url', help='A URL', type=URL())30@click.option('--url', help='A URL', type=URL)31@click.version_option()32def cli(count, foo, url):33 """Validation.34
10 unmodified lines