Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins: replace to_native(), to_text(), str() with str() where possible or leave it away in f-string formatting #9379

Merged
merged 4 commits into from
Dec 28, 2024

Conversation

felixfontein
Copy link
Collaborator

SUMMARY

With Python 3.6+ to_native() and to_text() are glorified str() calls assuming they are not potentially decoding byte strings to unicode strings. Remove them (in f-strings) or replace them with str() if possible.

ISSUE TYPE
  • Refactoring Pull Request
COMPONENT NAME

plugins/action/shutdown.py
plugins/cache/redis.py
plugins/callback/logentries.py
plugins/callback/slack.py
plugins/connection/chroot.py
plugins/filter/from_csv.py
plugins/filter/from_ini.py
plugins/filter/to_ini.py
plugins/inventory/cobbler.py
plugins/inventory/gitlab_runners.py
plugins/inventory/iocage.py
plugins/inventory/lxd.py
plugins/inventory/nmap.py
plugins/inventory/opennebula.py
plugins/inventory/proxmox.py
plugins/inventory/scaleway.py
plugins/inventory/virtualbox.py
plugins/lookup/cyberarkpassword.py
plugins/lookup/dig.py
plugins/lookup/dnstxt.py
plugins/lookup/etcd3.py
plugins/lookup/lmdb_kv.py
plugins/lookup/manifold.py
plugins/lookup/onepassword.py
plugins/lookup/tss.py

@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-10 Automatically create a backport for the stable-10 branch labels Dec 25, 2024
@ansibullbot ansibullbot added action action plugin cache cache plugin callback callback plugin cloud connection connection plugin filter filter plugin inventory inventory plugin lookup lookup plugin plugins plugin (any type) labels Dec 25, 2024
@felixfontein felixfontein requested a review from russoz December 25, 2024 21:44
@felixfontein
Copy link
Collaborator Author

If nobody objects, I'll merge this for the next release.

Copy link
Collaborator

@russoz russoz left a comment

Choose a reason for hiding this comment

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

Couple of adjustments, couple of maybes

plugins/inventory/iocage.py Show resolved Hide resolved
plugins/inventory/iocage.py Show resolved Hide resolved
plugins/inventory/lxd.py Show resolved Hide resolved
plugins/lookup/etcd3.py Show resolved Hide resolved
plugins/lookup/lmdb_kv.py Outdated Show resolved Hide resolved
felixfontein and others added 3 commits December 28, 2024 13:30
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
@ansibullbot
Copy link
Collaborator

@felixfontein felixfontein merged commit 2203560 into ansible-collections:main Dec 28, 2024
129 checks passed
Copy link

patchback bot commented Dec 28, 2024

Backport to stable-10: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-10/2203560867154d5aa496e911d78cd99f45c81f43/pr-9379

Backported as #9444

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Dec 28, 2024
@felixfontein felixfontein deleted the str branch December 28, 2024 21:47
patchback bot pushed a commit that referenced this pull request Dec 28, 2024
…ble or leave it away in f-string formatting (#9379)

* Replace to_native(), to_text(), str() with str() where possible or leave it away in f-string formatting.

* Improve formulation.

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>

* Use more f-strings.

* Remove unicode prefix for strings.

---------

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
(cherry picked from commit 2203560)
@felixfontein
Copy link
Collaborator Author

@russoz thanks for reviewing this!

felixfontein added a commit that referenced this pull request Dec 28, 2024
… to_text(), str() with str() where possible or leave it away in f-string formatting (#9444)

plugins: replace to_native(), to_text(), str() with str() where possible or leave it away in f-string formatting (#9379)

* Replace to_native(), to_text(), str() with str() where possible or leave it away in f-string formatting.

* Improve formulation.

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>

* Use more f-strings.

* Remove unicode prefix for strings.

---------

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
(cherry picked from commit 2203560)

Co-authored-by: Felix Fontein <felix@fontein.de>
Massl123 pushed a commit to Massl123/community.general that referenced this pull request Feb 7, 2025
…ble or leave it away in f-string formatting (ansible-collections#9379)

* Replace to_native(), to_text(), str() with str() where possible or leave it away in f-string formatting.

* Improve formulation.

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>

* Use more f-strings.

* Remove unicode prefix for strings.

---------

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action action plugin backport-10 Automatically create a backport for the stable-10 branch cache cache plugin callback callback plugin cloud connection connection plugin filter filter plugin inventory inventory plugin lookup lookup plugin plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants