display option context following option name instead of at the end for readability

pull/82731/head
s-hertel 3 months ago
parent 00f40c92db
commit f41d222eda

@ -195,11 +195,8 @@ def check_required_by(requirements, parameters, options_context=None, add_requir
if requirements is None:
return result
deprecation_fmt = (
'The explicit none (null) value specified to %s' +
(' found in {0}'.format(' -> '.join(options_context)) if options_context else '') +
' will not be treated as "not specified" in the future'
)
found_in = " found in %s" % " -> ".join(options_context) if options_context else ''
deprecation_fmt = f'The explicit none (null) value specified to %s{found_in} will not be treated as "not specified" in the future'
for (key, value) in requirements.items():
if key not in parameters or parameters[key] is None:
@ -377,13 +374,8 @@ def check_required_none(required_options, argument_spec, parameters, options_con
if allow_none_value:
continue
if allow_none_value is False:
msg = "required parameter %s cannot be none (null)" % (required_option, )
else:
msg = "required parameter %s is none (null)" % (required_option, )
if options_context:
msg += " found in %s" % " -> ".join(options_context)
found_in = " found in %s" % " -> ".join(options_context) if options_context else ''
msg = f"required parameter {required_option}{found_in} {'cannot be' if allow_none_value is False else 'is'} none (null)"
if allow_none_value is False:
raise TypeError(to_native(msg))
else:

@ -668,15 +668,15 @@
- argspec_required_together_fail is failed
- argspec_required_together_fail_none is succeeded
- "'required parameter other is none (null) found in required_together' == argspec_required_together_fail_none.deprecations[0]['msg']"
- "'required parameter other found in required_together is none (null)' == argspec_required_together_fail_none.deprecations[0]['msg']"
- argspec_required_if_fail_2 is failed
- argspec_required_if_fail_2_none is succeeded
- "'required parameter other is none (null) found in required_if' == argspec_required_if_fail_2_none.deprecations[0]['msg']"
- "'required parameter other found in required_if is none (null)' == argspec_required_if_fail_2_none.deprecations[0]['msg']"
- argspec_required_one_of_fail_2 is failed
- argspec_required_one_of_fail_2_none is succeeded
- "'required parameter thing is none (null) found in required_one_of' == argspec_required_one_of_fail_2_none.deprecations[0]['msg']"
- "'required parameter thing found in required_one_of is none (null)' == argspec_required_one_of_fail_2_none.deprecations[0]['msg']"
- argspec_required_by_fail_2 is failed
- argspec_required_by_fail_2_none_1 is failed

Loading…
Cancel
Save