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

Use PyUpgrade for 3.8+ for updating project #171

Merged
merged 2 commits into from
Mar 18, 2024
Merged

Use PyUpgrade for 3.8+ for updating project #171

merged 2 commits into from
Mar 18, 2024

Conversation

wbarnha
Copy link
Owner

@wbarnha wbarnha commented Mar 18, 2024

No description provided.

@wbarnha wbarnha self-assigned this Mar 18, 2024
Copy link

@code-review-doctor code-review-doctor bot left a 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)

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))

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))

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__,

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(

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(

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(

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(

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(

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"

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.

@wbarnha wbarnha merged commit fcca556 into master Mar 18, 2024
22 checks passed
@wbarnha wbarnha deleted the pyupgrade-38 branch March 18, 2024 18:07
@wbarnha wbarnha mentioned this pull request Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant