def test_docs(function): docstrings = function.__doc__ arguments = inspect.signature(function).parameters assert all([ _PARAMETER_MAPPING.get(argument, "Parameters") in docstrings for argument in arguments ])
def test_docs(function): docstrings = function.__doc__ arguments = inspect.signature(function).parameters valid_docs = defaultdict(set) for arg in arguments: valid = _PARAMETER_MAPPING.get(arg, "Parameters") in docstrings valid_docs[valid].add(arg) assert valid_docs[True] if valid_docs[False]: raise AssertionError( f"Wrong or missing docstrings for parameters {valid_docs[False]}.\n\n{docstrings}" ) assert all([argument in docstrings for argument in arguments])
def test_docs(function): docstrings = function.__doc__ arguments = inspect.signature(function).parameters valid_docs = defaultdict(set) for arg in arguments: valid = _PARAMETER_MAPPING.get(arg, "Parameters") in docstrings valid_docs[valid].add(arg) assert valid_docs[True] if valid_docs[False]: raise AssertionError( f"Wrong or missing docstrings for parameters {valid_docs[False]}.\n\n{docstrings}" ) sorted_arguments = sorted(arguments) args_in_docs = [argument in docstrings for argument in sorted_arguments] assert all(args_in_docs), [ sorted_arguments[ix] for ix, val in enumerate(args_in_docs) if val is False ]