refactor: comply with Ansible partner certification checks [citest_skip]#277
Conversation
https://github.com/ansible-collections/partner-certification-checker/blob/main/README.md Ensure that our code complies with these policies/checks and prepare for improved ansible-lint and ansible-test checks. Signed-off-by: Rich Megginson <rmeggins@redhat.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRefactors filter plugin type checking to avoid deprecated ansible six usage, normalizes YAML documents to include explicit YAML start markers, and updates/extends Ansible sanity ignore configuration files for newer Ansible versions. Flow diagram for updated from_ini type checking logicflowchart TD
A[Input obj to from_ini] --> B{Is obj instance of lsr_string_types?}
B -- Yes --> C[Proceed to parse obj as INI text]
C --> D[Build dictionary rv from INI contents]
D --> E[Return rv]
B -- No --> F[Raise AnsibleFilterError with message from_ini requires a str]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Given that current supported Ansible/Python versions are Python 3 only, the
lsr_string_typesshim usingbasestringis likely unnecessary and could be simplified to a directisinstance(obj, str)check to reduce compatibility cruft.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Given that current supported Ansible/Python versions are Python 3 only, the `lsr_string_types` shim using `basestring` is likely unnecessary and could be simplified to a direct `isinstance(obj, str)` check to reduce compatibility cruft.
## Individual Comments
### Comment 1
<location path="filter_plugins/podman_from_ini.py" line_range="47-50" />
<code_context>
+
+# ansible six is deprecated, and it seems a lot to add a dependency on python-six
+# just for this
+try:
+ lsr_string_types = (basestring,)
+except NameError:
+ lsr_string_types = (str,)
</code_context>
<issue_to_address>
**suggestion:** Consider simplifying type handling now that supported Ansible/Python versions are Python 3 only.
Given Ansible 2.14+ is Python 3–only (including the 2.20/2.21 targets referenced by the new sanity ignore files), you can drop the Python 2 compatibility shim and set `lsr_string_types = (str,)` directly. This avoids unused legacy code and simplifies the implementation.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| try: | ||
| lsr_string_types = (basestring,) | ||
| except NameError: | ||
| lsr_string_types = (str,) |
There was a problem hiding this comment.
suggestion: Consider simplifying type handling now that supported Ansible/Python versions are Python 3 only.
Given Ansible 2.14+ is Python 3–only (including the 2.20/2.21 targets referenced by the new sanity ignore files), you can drop the Python 2 compatibility shim and set lsr_string_types = (str,) directly. This avoids unused legacy code and simplifies the implementation.
https://github.com/ansible-collections/partner-certification-checker/blob/main/README.md
Ensure that our code complies with these policies/checks and prepare for
improved ansible-lint and ansible-test checks.
Signed-off-by: Rich Megginson rmeggins@redhat.com
Summary by Sourcery
Align the role with current Ansible partner certification and tooling requirements.
Enhancements:
Tests: