Skip to content

refactor: comply with Ansible partner certification checks [citest_skip]#277

Merged
richm merged 1 commit intolinux-system-roles:mainfrom
richm:refactor-comply-with-ansible-partner-cert-checks
Apr 4, 2026
Merged

refactor: comply with Ansible partner certification checks [citest_skip]#277
richm merged 1 commit intolinux-system-roles:mainfrom
richm:refactor-comply-with-ansible-partner-cert-checks

Conversation

@richm
Copy link
Copy Markdown
Contributor

@richm richm commented Apr 4, 2026

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:

  • Replace deprecated ansible.module_utils.six string type usage with an internal compatibility alias.
  • Add explicit YAML document start markers to filter plugin metadata and test configuration files.

Tests:

  • Add new Ansible sanity ignore configuration files for Ansible 2.20 and 2.21 versions.

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>
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 4, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors 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 logic

flowchart 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]
Loading

File-Level Changes

Change Details Files
Replace deprecated ansible.module_utils.six string type usage with a local Python 2/3 compatible string type definition.
  • Remove import of string_types from ansible.module_utils.six.
  • Introduce lsr_string_types defined via basestring when available, otherwise str.
  • Update from_ini input validation to use lsr_string_types for isinstance checks.
filter_plugins/podman_from_ini.py
Ensure YAML documents have an explicit document start marker for ansible-lint/partner certification compliance.
  • Add '---' YAML document start marker to podman_from_ini filter plugin metadata YAML.
  • Add '---' YAML document start marker to podman_to_toml filter plugin metadata YAML.
  • Add '---' YAML document start marker to osbuild_config test YAML.
filter_plugins/podman_from_ini.yml
filter_plugins/podman_to_toml.yml
tests/osbuild_config.yml
Align Ansible sanity ignore configuration with supported/tested Ansible versions, including newer releases.
  • Touch or adjust existing .sanity-ansible-ignore files for Ansible 2.14, 2.15, and 2.16 (no diff content shown, but files are part of the PR).
  • Introduce new .sanity-ansible-ignore files for Ansible 2.20 and 2.21 to control sanity test expectations for those versions.
.sanity-ansible-ignore-2.14.txt
.sanity-ansible-ignore-2.15.txt
.sanity-ansible-ignore-2.16.txt
.sanity-ansible-ignore-2.20.txt
.sanity-ansible-ignore-2.21.txt

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_types shim using basestring is likely unnecessary and could be simplified to a direct isinstance(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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +47 to +50
try:
lsr_string_types = (basestring,)
except NameError:
lsr_string_types = (str,)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@richm richm merged commit 0a52179 into linux-system-roles:main Apr 4, 2026
11 checks passed
@richm richm deleted the refactor-comply-with-ansible-partner-cert-checks branch April 4, 2026 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant