Skip to content

Commit

Permalink
fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dimastbk committed May 17, 2024
1 parent f5dee1b commit 512461f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions aiokafka/coordinator/assignors/sticky/sticky_assignor.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,14 @@ def _initialize_current_subscriptions(self) -> None:
)

def _get_consumer_with_least_subscriptions(self) -> str:
return self.sorted_current_subscriptions.first()[0]
if current_subscription := self.sorted_current_subscriptions.first():
return current_subscription[0]
raise ValueError("sorted_current_subscriptions is empty")

Check warning on line 424 in aiokafka/coordinator/assignors/sticky/sticky_assignor.py

View check run for this annotation

Codecov / codecov/patch

aiokafka/coordinator/assignors/sticky/sticky_assignor.py#L424

Added line #L424 was not covered by tests

def _get_consumer_with_most_subscriptions(self) -> str:
return self.sorted_current_subscriptions.last()[0]
if current_subscription := self.sorted_current_subscriptions.last():
return current_subscription[0]
raise ValueError("sorted_current_subscriptions is empty")

Check warning on line 429 in aiokafka/coordinator/assignors/sticky/sticky_assignor.py

View check run for this annotation

Codecov / codecov/patch

aiokafka/coordinator/assignors/sticky/sticky_assignor.py#L429

Added line #L429 was not covered by tests

def _remove_consumer_from_current_subscriptions_and_maintain_order(
self, consumer: str
Expand Down Expand Up @@ -548,7 +552,8 @@ def _perform_reassignments(
)

if (
partition in self.previous_assignment
consumer is not None
and partition in self.previous_assignment
and len(self.current_assignment[consumer])
> len(
self.current_assignment[
Expand All @@ -571,7 +576,8 @@ def _perform_reassignments(
partition
]:
if (
len(self.current_assignment[consumer])
consumer is not None
and len(self.current_assignment[consumer])
> len(self.current_assignment[other_consumer]) + 1
):
self._reassign_partition(partition)
Expand Down

0 comments on commit 512461f

Please sign in to comment.