fix[doc.py]: path will be undefined (#84464)

* fix[doc.py]: path will be undefined and a direct reference will throw an UnboundLocalError.

If none of the files in files exists, path will be undefined and a direct reference will throw an UnboundLocalError.
Repair function file parameter type annotation is inaccurate

* Update changelogs/fragments/fix-cli-doc-path_undefined.yaml

Co-authored-by: Sloane Hertel <19572925+s-hertel@users.noreply.github.com>

---------

Co-authored-by: Brian Coca <bcoca@users.noreply.github.com>
Co-authored-by: Sloane Hertel <19572925+s-hertel@users.noreply.github.com>
pull/84554/head
Harilou 11 months ago committed by GitHub
parent e151cd765d
commit d79b706c06
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,2 @@
bugfixes:
- ansible-doc - If none of the files in files exists, path will be undefined and a direct reference will throw an UnboundLocalError (https://github.com/ansible/ansible/pull/84464).

@ -104,7 +104,7 @@ class RoleMixin(object):
""" Load and process the YAML for the first found of a set of role files
:param str root: The root path to get the files from
:param str files: List of candidate file names in order of precedence
:param list files: List of candidate file names in order of precedence
:param str role_name: The name of the role for which we want the argspec data.
:param str collection: collection name or None in case of stand alone roles
@ -117,6 +117,7 @@ class RoleMixin(object):
meta_path = os.path.join(root, 'meta')
# Check all potential spec files
path = None
for specfile in files:
full_path = os.path.join(meta_path, specfile)
if os.path.exists(full_path):

Loading…
Cancel
Save