def key_if_required(key: str, required: bool = True) -> dict:
"""
Check if key is required and return a dictionary.
:param `key`: The name of the key to check
:param `required`: Whether the key is required or not
:returns: Dictionary
"""
if key not in ["dogs", "cats"]:
return {"default": key}
return {"required": required}
darglint will report these errors when using Sphinx formatting:
Given the following function:
darglint will report these errors when using Sphinx formatting:
The backticks are nice because they allow highlighting in editors. If there were an option to ignore backticks for arguments that would be great.