- Make readuserdict compatible with click 8.x
read_user_dict function uses a "default" sentinel instead of the actual
default value. Being a JSON dict, the latter would often be hard to type.
Under click 8.x, the default value for
click.prompt is passed to the
read_proc callback. We use this callback to load JSON from the user input, and
this would choke on an input like "default" (without quotes). Therefore, change
the callback to return the default value when it receives the "default"
Under click 7.x (which is our minimum version), the default value for
click.prompt is returned as-is. Therefore, continue to handle the case where
click.prompt returns "default" instead of the actual default value, but only
if we're actually running under click 7.x.
(Checking for click 7.x is only done for clarity. Under click 8.x,
click.prompt would never return "default", even if a user entered it as a
valid JSON string. This is because our callback requires a dict, not a string.)
- test: Expect readuserdict to call click.prompt with partial object
Previously, tests for
process_json to be passed to
click.prompt directly. Instead, we now pass an instance of
so adapt the mock to reflect that.
- test: Avoid mocking
click.promptwhen testing defaults
Do not mock
click.prompt when testing that
read_user_dict returns the proper
default value (rather than the sentinel "default"). Mocking
prevents our callback from running, and under click >= 8.0 we process the
sentinel in the callback. Instead, use
click.testing.CliRunner to fake
- test: Adapt regression test for default handling
json.loads not to be called with the sentinel ("default"). Previously,
the test expected
process_json not to be called, but under click >= 8.0 that
is now where we handle the sentinel.
- Update dependencies for click 8.x