diff --git a/docs/docsite/rst/dev_guide/testing_validate-modules.rst b/docs/docsite/rst/dev_guide/testing_validate-modules.rst index f2be1b68598..91a03eb28ea 100644 --- a/docs/docsite/rst/dev_guide/testing_validate-modules.rst +++ b/docs/docsite/rst/dev_guide/testing_validate-modules.rst @@ -129,6 +129,8 @@ Errors 334 ``ANSIBLE_METADATA`` cannot be changed in a point release for a stable branch 335 argument_spec implies type="str" but documentation defines it as different data type 336 argument in argument_spec is not a valid python identifier + 337 Type value is defined in ``argument_spec`` but documentation doesn't specify a type + 338 documentation doesn't specify a type but argument in ``argument_spec`` use default type (``str``) .. --------- ------------------- **4xx** **Syntax** diff --git a/test/sanity/validate-modules/main.py b/test/sanity/validate-modules/main.py index 50c567b0fca..5e3de8626bd 100755 --- a/test/sanity/validate-modules/main.py +++ b/test/sanity/validate-modules/main.py @@ -1245,8 +1245,16 @@ class ModuleValidator(Validator): # TODO: needs to recursively traverse suboptions doc_type = docs.get('options', {}).get(arg, {}).get('type') - if 'type' in data: - if data['type'] != doc_type and doc_type is not None: + if 'type' in data and data['type'] is not None: + if doc_type is None: + if not arg.startswith('_'): # hidden parameter, for example _raw_params + self.reporter.error( + path=self.object_path, + code=337, + msg="Argument '%s' in argument_spec defines type as %r " + "but documentation doesn't define type" % (arg, data['type']) + ) + elif data['type'] != doc_type: self.reporter.error( path=self.object_path, code=325, @@ -1254,7 +1262,14 @@ class ModuleValidator(Validator): "but documentation defines type as %r" % (arg, data['type'], doc_type) ) else: - if doc_type != 'str' and doc_type is not None: + if doc_type is None: + self.reporter.error( + path=self.object_path, + code=338, + msg="Argument '%s' in argument_spec uses default type ('str') " + "but documentation doesn't define type" % (arg) + ) + elif doc_type != 'str': self.reporter.error( path=self.object_path, code=335,