Techdebt: Replace string-format with f-strings (#5695)
This commit is contained in:
parent
9fab501c2e
commit
b4f59b771c
@ -45,7 +45,7 @@ class Version:
|
|||||||
self.parse(vstring)
|
self.parse(vstring)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "%s ('%s')" % (self.__class__.__name__, str(self))
|
return f"{self.__class__.__name__} ('{self}')"
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
c = self._cmp(other)
|
c = self._cmp(other)
|
||||||
@ -217,7 +217,7 @@ class LooseVersion(Version):
|
|||||||
return self.vstring
|
return self.vstring
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "LooseVersion ('%s')" % str(self)
|
return f"LooseVersion ('{self}')"
|
||||||
|
|
||||||
def _cmp(self, other):
|
def _cmp(self, other):
|
||||||
if isinstance(other, str):
|
if isinstance(other, str):
|
||||||
|
@ -20,9 +20,7 @@ def paginate(
|
|||||||
model = pagination_model
|
model = pagination_model
|
||||||
pagination_config = model.get(method)
|
pagination_config = model.get(method)
|
||||||
if not pagination_config:
|
if not pagination_config:
|
||||||
raise ValueError(
|
raise ValueError(f"No pagination config for backend method: {method}")
|
||||||
"No pagination config for backend method: {}".format(method)
|
|
||||||
)
|
|
||||||
# Get the pagination arguments, to be used by the paginator
|
# Get the pagination arguments, to be used by the paginator
|
||||||
next_token_name = pagination_config.get("input_token", "next_token")
|
next_token_name = pagination_config.get("input_token", "next_token")
|
||||||
limit_name = pagination_config.get("limit_key")
|
limit_name = pagination_config.get("limit_key")
|
||||||
@ -100,9 +98,7 @@ class Paginator(object):
|
|||||||
self._raise_exception_if_required(next_token)
|
self._raise_exception_if_required(next_token)
|
||||||
return None
|
return None
|
||||||
if next_token.get("parameterChecksum") != self._param_checksum:
|
if next_token.get("parameterChecksum") != self._param_checksum:
|
||||||
raise InvalidToken(
|
raise InvalidToken(f"Input inconsistent with page token: {str(next_token)}")
|
||||||
"Input inconsistent with page token: {}".format(str(next_token))
|
|
||||||
)
|
|
||||||
return next_token
|
return next_token
|
||||||
|
|
||||||
def _raise_exception_if_required(self, token):
|
def _raise_exception_if_required(self, token):
|
||||||
|
@ -5,7 +5,7 @@ class BadSegmentException(Exception):
|
|||||||
self.message = message
|
self.message = message
|
||||||
|
|
||||||
def __repr__(self):
|
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):
|
def to_dict(self):
|
||||||
result = {}
|
result = {}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
black==22.3.0
|
black==22.3.0
|
||||||
flake8==4.0.1
|
flake8==4.0.1
|
||||||
flake8-print
|
flake8-print
|
||||||
|
flake8-use-fstring
|
||||||
click
|
click
|
||||||
inflection
|
inflection
|
||||||
lxml
|
lxml
|
||||||
|
@ -3914,7 +3914,7 @@ def test_transact_write_items_put_conditional_expressions_return_values_on_condi
|
|||||||
{
|
{
|
||||||
"Put": {
|
"Put": {
|
||||||
"Item": {
|
"Item": {
|
||||||
"id": {"S": "foo{}".format(str(i))},
|
"id": {"S": f"foo{i}"},
|
||||||
"foo": {"S": "bar"},
|
"foo": {"S": "bar"},
|
||||||
},
|
},
|
||||||
"TableName": "test-table",
|
"TableName": "test-table",
|
||||||
|
Loading…
Reference in New Issue
Block a user