Techdebt: Replace string-format with f-strings (#5695)

This commit is contained in:
Bert Blommers 2022-11-21 22:20:19 -01:00 committed by GitHub
parent 9fab501c2e
commit b4f59b771c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 10 deletions

View File

@ -45,7 +45,7 @@ class Version:
self.parse(vstring)
def __repr__(self):
return "%s ('%s')" % (self.__class__.__name__, str(self))
return f"{self.__class__.__name__} ('{self}')"
def __eq__(self, other):
c = self._cmp(other)
@ -217,7 +217,7 @@ class LooseVersion(Version):
return self.vstring
def __repr__(self):
return "LooseVersion ('%s')" % str(self)
return f"LooseVersion ('{self}')"
def _cmp(self, other):
if isinstance(other, str):

View File

@ -20,9 +20,7 @@ def paginate(
model = pagination_model
pagination_config = model.get(method)
if not pagination_config:
raise ValueError(
"No pagination config for backend method: {}".format(method)
)
raise ValueError(f"No pagination config for backend method: {method}")
# Get the pagination arguments, to be used by the paginator
next_token_name = pagination_config.get("input_token", "next_token")
limit_name = pagination_config.get("limit_key")
@ -100,9 +98,7 @@ class Paginator(object):
self._raise_exception_if_required(next_token)
return None
if next_token.get("parameterChecksum") != self._param_checksum:
raise InvalidToken(
"Input inconsistent with page token: {}".format(str(next_token))
)
raise InvalidToken(f"Input inconsistent with page token: {str(next_token)}")
return next_token
def _raise_exception_if_required(self, token):

View File

@ -5,7 +5,7 @@ class BadSegmentException(Exception):
self.message = message
def __repr__(self):
return "<BadSegment {0}>".format("-".join([self.id, self.code, self.message]))
return f"<BadSegment {self.id}-{self.code}-{self.message}>"
def to_dict(self):
result = {}

View File

@ -4,6 +4,7 @@
black==22.3.0
flake8==4.0.1
flake8-print
flake8-use-fstring
click
inflection
lxml

View File

@ -3914,7 +3914,7 @@ def test_transact_write_items_put_conditional_expressions_return_values_on_condi
{
"Put": {
"Item": {
"id": {"S": "foo{}".format(str(i))},
"id": {"S": f"foo{i}"},
"foo": {"S": "bar"},
},
"TableName": "test-table",