diff options
author | Harilou <1084430062@qq.com> | 2025-01-14 16:33:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-14 16:33:43 +0100 |
commit | d79b706c06e84e3c294994de7f62dbcadff90101 (patch) | |
tree | 1b1943698eacc76e6e5a604be66bea83acf56a78 | |
parent | `with_dict` type error include value in error message (#84473) (diff) | |
download | ansible-d79b706c06e84e3c294994de7f62dbcadff90101.tar.xz ansible-d79b706c06e84e3c294994de7f62dbcadff90101.zip |
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>
-rw-r--r-- | changelogs/fragments/fix-cli-doc-path_undefined.yaml | 2 | ||||
-rwxr-xr-x | lib/ansible/cli/doc.py | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/changelogs/fragments/fix-cli-doc-path_undefined.yaml b/changelogs/fragments/fix-cli-doc-path_undefined.yaml new file mode 100644 index 0000000000..9a62bf7738 --- /dev/null +++ b/changelogs/fragments/fix-cli-doc-path_undefined.yaml @@ -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). diff --git a/lib/ansible/cli/doc.py b/lib/ansible/cli/doc.py index 52ec8a6c7b..6efe0319e5 100755 --- a/lib/ansible/cli/doc.py +++ b/lib/ansible/cli/doc.py @@ -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): |