-
Notifications
You must be signed in to change notification settings - Fork 11
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
Use PyUpgrade for 3.8+ for updating project #171
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some things to consider. View full project report here.
@@ -374,7 +368,7 @@ def _maybe_connect(self, node_id): | |||
|
|||
if conn is None: | |||
broker = self.cluster.broker_metadata(node_id) | |||
assert broker, 'Broker id %s not in current metadata' % (node_id,) | |||
assert broker, 'Broker id {} not in current metadata'.format(node_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f-string is easier to read, write, and less computationally expensive than legacy string formatting. Explained here.
@@ -772,7 +764,7 @@ def send_pending_requests(self): | |||
|
|||
except (ConnectionError, TimeoutError) as e: | |||
log.exception("Error sending request data to %s", self) | |||
error = Errors.KafkaConnectionError("%s: %s" % (self, e)) | |||
error = Errors.KafkaConnectionError("{}: {}".format(self, e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f-string is easier to read, write, and less computationally expensive than legacy string formatting. Read more.
@@ -805,7 +797,7 @@ def send_pending_requests_v2(self): | |||
|
|||
except (ConnectionError, TimeoutError, Exception) as e: | |||
log.exception("Error sending request data to %s", self) | |||
error = Errors.KafkaConnectionError("%s: %s" % (self, e)) | |||
error = Errors.KafkaConnectionError("{}: {}".format(self, e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, Consider using f-string instead.
@@ -12,8 +10,8 @@ class KafkaError(RuntimeError): | |||
def __str__(self): | |||
if not self.args: | |||
return self.__class__.__name__ | |||
return '{0}: {1}'.format(self.__class__.__name__, | |||
super(KafkaError, self).__str__()) | |||
return '{}: {}'.format(self.__class__.__name__, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f-string is easier to read, write, and less computationally expensive than legacy string formatting. More info.
@@ -96,9 +94,9 @@ class BrokerResponseError(KafkaError): | |||
|
|||
def __str__(self): | |||
"""Add errno to standard KafkaError str""" | |||
return '[Error {0}] {1}'.format( | |||
return '[Error {}] {}'.format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise, Consider using f-string instead.
@@ -102,5 +100,5 @@ def __ne__(self, other): | |||
return not self.__eq__(other) | |||
|
|||
def __str__(self): | |||
return 'MetricName(name=%s, group=%s, description=%s, tags=%s)' % ( | |||
return 'MetricName(name={}, group={}, description={}, tags={})'.format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f-string is easier to read, write, and less computationally expensive than legacy string formatting. Read more.
@@ -110,7 +108,7 @@ def maybe_expire(self, request_timeout_ms, retry_backoff_ms, linger_ms, is_full) | |||
if error: | |||
self.records.close() | |||
self.done(-1, None, Errors.KafkaTimeoutError( | |||
"Batch for %s containing %s record(s) expired: %s" % ( | |||
"Batch for {} containing {} record(s) expired: {}".format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f-string is easier to read, write, and less computationally expensive than legacy string formatting. More info.
if invalid_names: | ||
raise ValueError('Invalid enum member name(s): %s' % ( | ||
', '.join(invalid_names), )) | ||
raise ValueError('Invalid enum member name(s): {}'.format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f-string is easier to read, write, and less computationally expensive than legacy string formatting. More.
temp_enum_dict['__new__'] = __new__ | ||
del __new__ | ||
|
||
def __repr__(self): | ||
return "<%s.%s: %r>" % ( | ||
return "<{}.{}: {!r}>".format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above: Consider using f-string instead.
|
||
key = SelectorKey(fileobj, self._fileobj_lookup(fileobj), events, data) | ||
|
||
if key.fd in self._fd_to_key: | ||
raise KeyError("{0!r} (FD {1}) is already registered" | ||
raise KeyError("{!r} (FD {}) is already registered" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f-string is easier to read, write, and less computationally expensive than legacy string formatting. More details.
No description provided.