Skip to content

Commit

Permalink
Update ruff to 0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ods committed Mar 12, 2024
1 parent 9363315 commit 6ad086b
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 51 deletions.
9 changes: 4 additions & 5 deletions aiokafka/admin/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,15 @@ def _matching_api_version(self, operation: list[Request]) -> int:
api_key = operation[0].API_KEY
if not self._version_info or api_key not in self._version_info:
raise IncompatibleBrokerVersion(
"Kafka broker does not support the '{}' Kafka protocol.".format(
operation[0].__name__
)
f"Kafka broker does not support the '{operation[0].__name__}' "
"Kafka protocol."
)
min_version, max_version = self._version_info[api_key]
version = min(len(operation) - 1, max_version)
if version < min_version:
raise IncompatibleBrokerVersion(
"No version of the '{}' Kafka protocol is supported by "
"both the client and broker.".format(operation[0].__name__)
f"No version of the '{operation[0].__name__}' Kafka protocol "
"is supported by both the client and broker."
)
return version

Expand Down
8 changes: 3 additions & 5 deletions aiokafka/metrics/metric_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ def __ne__(self, other):
return not self.__eq__(other)

def __str__(self):
return "MetricName(name={}, group={}, description={}, tags={})".format(
self.name,
self.group,
self.description,
self.tags,
return (
f"MetricName(name={self.name}, group={self.group}, "
f"description={self.description}, tags={self.tags})"
)
5 changes: 2 additions & 3 deletions aiokafka/record/memory_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ def next_batch(self, _min_slice=MIN_SLICE, _magic_offset=MAGIC_OFFSET):
return None
if len(next_slice) < _min_slice:
raise CorruptRecordException(
"Record size is less than the minimum record overhead ({})".format(
_min_slice - self.LOG_OVERHEAD
)
"Record size is less than the minimum record overhead "
f"({_min_slice - self.LOG_OVERHEAD})"
)
self._cache_next()
magic = next_slice[_magic_offset]
Expand Down
2 changes: 1 addition & 1 deletion requirements-ci.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-r requirements-cython.txt
ruff==0.3.0
ruff==0.3.2
mypy==1.8.0
pytest==7.4.3
pytest-cov==4.1.0
Expand Down
2 changes: 1 addition & 1 deletion requirements-win-test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-r requirements-cython.txt
ruff==0.3.0
ruff==0.3.2
mypy==1.8.0
pytest==7.4.3
pytest-cov==4.1.0
Expand Down
47 changes: 14 additions & 33 deletions tests/coordinator/test_assignors.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,16 +995,10 @@ def verify_validity_and_balance(subscriptions, assignment):
set(other_partitions)
)
assert partitions_intersection == set(), (
"Error: Consumers {} and {} have common partitions "
"assigned to them: {}\n"
"Subscriptions: {}\n"
"Assignments: {}".format(
consumer,
other_consumer,
partitions_intersection,
subscriptions,
assignment,
)
f"Error: Consumers {consumer} and {other_consumer} have common "
f"partitions assigned to them: {partitions_intersection}\n"
f"Subscriptions: {subscriptions}\n"
f"Assignments: {assignment}"
)

if abs(len(partitions) - len(other_partitions)) <= 1:
Expand All @@ -1015,34 +1009,21 @@ def verify_validity_and_balance(subscriptions, assignment):
if len(partitions) > len(other_partitions):
for topic in assignments_by_topic:
assert topic not in other_assignments_by_topic, (
"Error: Some partitions can be moved from {} ({} partitions) "
"to {} ({} partitions) "
f"Error: Some partitions can be moved from {consumer} "
f"({len(partitions)} partitions) to {other_consumer} "
f"({len(other_partitions)} partitions) "
"to achieve a better balance\n"
"Subscriptions: {}\n"
"Assignments: {}".format(
consumer,
len(partitions),
other_consumer,
len(other_partitions),
subscriptions,
assignment,
)
f"Subscriptions: {subscriptions}\n"
f"Assignments: {assignment}"
)
if len(other_partitions) > len(partitions):
for topic in other_assignments_by_topic:
assert topic not in assignments_by_topic, (
"Error: Some partitions can be moved from {} ({} partitions) "
"to {} ({} partitions) "
"to achieve a better balance\n"
"Subscriptions: {}\n"
"Assignments: {}".format(
other_consumer,
len(other_partitions),
consumer,
len(partitions),
subscriptions,
assignment,
)
f"Error: Some partitions can be moved from {other_consumer} "
f"({len(other_partitions)} partitions) to {consumer} "
f"({len(partitions)} partitions) to achieve a better balance\n"
f"Subscriptions: {subscriptions}\n"
f"Assignments: {assignment}"
)


Expand Down
5 changes: 2 additions & 3 deletions tests/record/test_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,8 @@ def test_legacy_correct_metadata_response(magic):
assert meta.timestamp == (9999999 if magic else -1)
assert meta.crc == (-2095076219 if magic else 278251978) & 0xFFFFFFFF
assert repr(meta) == (
"LegacyRecordMetadata(offset=0, crc={}, size={}, timestamp={})".format(
meta.crc, meta.size, meta.timestamp
)
f"LegacyRecordMetadata(offset=0, crc={meta.crc}, size={meta.size}, "
f"timestamp={meta.timestamp})"
)


Expand Down

0 comments on commit 6ad086b

Please sign in to comment.