1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-02-04 07:51:50 +00:00

use f-strings in module utils (#10901)

* use f-strings in module utils

* Apply suggestions from code review

Co-authored-by: Felix Fontein <felix@fontein.de>

* remove unused imports

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Alexei Znamensky 2025-10-11 22:43:43 +13:00 committed by GitHub
parent 74b6a0294a
commit b85e263466
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
51 changed files with 270 additions and 382 deletions

View file

@ -98,8 +98,9 @@ class _Variable(object):
return
def __str__(self):
return "<Variable: value={0!r}, initial={1!r}, diff={2}, output={3}, change={4}, verbosity={5}>".format(
self.value, self.initial_value, self.diff, self.output, self.change, self.verbosity
return (
f"<Variable: value={self.value!r}, initial={self.initial_value!r}, diff={self.diff}, "
f"output={self.output}, change={self.change}, verbosity={self.verbosity}>"
)
@ -163,7 +164,7 @@ class VarDict(object):
ValueError: Raised if trying to set a variable with a reserved name.
"""
if name in self.reserved_names:
raise ValueError("Name {0} is reserved".format(name))
raise ValueError(f"Name {name} is reserved")
if name in self.__vars__:
var = self._var(name)
var.set_meta(**kwargs)