refactor: the ansible six PY2 is deprecated - just use sys.version_info instead#324
Merged
richm merged 1 commit intolinux-system-roles:mainfrom Apr 1, 2026
Conversation
…fo instead Fixes the following ansible-test error: ``` ERROR: plugins/module_utils/certificate_lsr/providers/base.py:90:0: ansible-bad-import-from: Import PY2 from the Python standard library equivalent instead of ansible.module_utils.six ``` PY2 is only used to determine the name of an exception, which can be done using sys.version_info instead. This also adds ansible-test ignores files for all tested versions. Signed-off-by: Rich Megginson <rmeggins@redhat.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideReplaces deprecated ansible.module_utils.six.PY2 usage with a direct sys.version_info check in the certificate provider base module, and adds ansible-test sanity ignore files for multiple Ansible versions. Flow diagram for Python version-dependent FileNotFoundError alias using sys.version_infoflowchart TD
start[[Module_import]] --> check_version["Check sys.version_info[0]"]
check_version -->|== 2| alias_ioerror["Set FileNotFoundError = IOError (for Python 2)"]
check_version -->|!= 2| keep_builtin["Keep built-in FileNotFoundError (Python 3)"]
alias_ioerror --> module_runtime[[Module_runtime]]
keep_builtin --> module_runtime
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 left some high level feedback:
- The new
sys.version_info[0] == 2check usessyswithout importing it; add an explicitimport sysat the top of the module to avoid a NameError.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `sys.version_info[0] == 2` check uses `sys` without importing it; add an explicit `import sys` at the top of the module to avoid a NameError.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Collaborator
Author
|
[citest] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the following ansible-test error:
PY2 is only used to determine the name of an exception, which can be done using sys.version_info
instead.
This also adds ansible-test ignores files for all tested versions.
Signed-off-by: Rich Megginson rmeggins@redhat.com
Summary by Sourcery
Replace deprecated Python 2 detection in certificate provider utilities and add ansible-test ignore configuration for supported Ansible versions.
Enhancements:
CI: