Skip to content

Commit 052d740

Browse files
authored
python3 updates: drop class object, super() (#2837)
1 parent 24aff0a commit 052d740

18 files changed

Lines changed: 41 additions & 41 deletions

File tree

kafka/admin/acl_resource.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def __init__(
160160
permission_type,
161161
resource_pattern
162162
):
163-
super(ACL, self).__init__(principal, host, operation, permission_type, resource_pattern)
163+
super().__init__(principal, host, operation, permission_type, resource_pattern)
164164
self.validate()
165165

166166
def validate(self):
@@ -231,7 +231,7 @@ def __init__(
231231
resource_name,
232232
pattern_type=ACLResourcePatternType.LITERAL
233233
):
234-
super(ResourcePattern, self).__init__(resource_type, resource_name, pattern_type)
234+
super().__init__(resource_type, resource_name, pattern_type)
235235
self.validate()
236236

237237
def validate(self):

kafka/benchmarks/consumer_performance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def run(args):
7171

7272
class StatsReporter(threading.Thread):
7373
def __init__(self, interval, consumer, event=None, raw_metrics=False):
74-
super(StatsReporter, self).__init__()
74+
super().__init__()
7575
self.interval = interval
7676
self.consumer = consumer
7777
self.event = event

kafka/benchmarks/load_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
class Producer(threading.Thread):
1212

1313
def __init__(self, bootstrap_servers, topic, stop_event, msg_size):
14-
super(Producer, self).__init__()
14+
super().__init__()
1515
self.bootstrap_servers = bootstrap_servers
1616
self.topic = topic
1717
self.stop_event = stop_event
@@ -30,7 +30,7 @@ def run(self):
3030

3131
class Consumer(threading.Thread):
3232
def __init__(self, bootstrap_servers, topic, stop_event, msg_size):
33-
super(Consumer, self).__init__()
33+
super().__init__()
3434
self.bootstrap_servers = bootstrap_servers
3535
self.topic = topic
3636
self.stop_event = stop_event

kafka/benchmarks/producer_performance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def _benchmark():
8282

8383
class StatsReporter(threading.Thread):
8484
def __init__(self, interval, producer, event=None, raw_metrics=False):
85-
super(StatsReporter, self).__init__()
85+
super().__init__()
8686
self.interval = interval
8787
self.producer = producer
8888
self.event = event

kafka/coordinator/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ def __init__(self, heartbeat, metrics, prefix, tags=None):
10891089

10901090
class HeartbeatThread(threading.Thread):
10911091
def __init__(self, coordinator):
1092-
super(HeartbeatThread, self).__init__()
1092+
super().__init__()
10931093
self.name = coordinator.group_id + '-heartbeat'
10941094
self.coordinator = coordinator
10951095
self.enabled = False

kafka/coordinator/consumer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def __init__(self, client, subscription, **configs):
8686
True the only way to receive records from an internal topic is
8787
subscribing to it. Requires 0.10+. Default: True
8888
"""
89-
super(ConsumerCoordinator, self).__init__(client, **configs)
89+
super().__init__(client, **configs)
9090

9191
self.config = copy.copy(self.DEFAULT_CONFIG)
9292
for key in self.config:
@@ -149,7 +149,7 @@ def __del__(self):
149149
self._cluster.remove_listener(WeakMethod(self._handle_metadata_update))
150150
except TypeError:
151151
pass
152-
super(ConsumerCoordinator, self).__del__()
152+
super().__del__()
153153

154154
def protocol_type(self):
155155
return ConsumerProtocolType
@@ -403,7 +403,7 @@ def need_rejoin(self):
403403
and self._joined_subscription != self._subscription.subscription):
404404
return True
405405

406-
return super(ConsumerCoordinator, self).need_rejoin()
406+
return super().need_rejoin()
407407

408408
def refresh_committed_offsets_if_needed(self, timeout_ms=None):
409409
"""Fetch committed offsets for assigned partitions."""
@@ -477,7 +477,7 @@ def close(self, autocommit=True, timeout_ms=None):
477477
if autocommit:
478478
self._maybe_auto_commit_offsets_sync(timeout_ms=timeout_ms)
479479
finally:
480-
super(ConsumerCoordinator, self).close(timeout_ms=timeout_ms)
480+
super().close(timeout_ms=timeout_ms)
481481

482482
def _invoke_completed_offset_commit_callbacks(self):
483483
if self._async_commit_fenced:

kafka/errors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def __str__(self):
1111
if not self.args:
1212
return self.__class__.__name__
1313
return '{0}: {1}'.format(self.__class__.__name__,
14-
super(KafkaError, self).__str__())
14+
super().__str__())
1515

1616
def __eq__(self, other):
1717
return self.__class__ == other.__class__ and self.args == other.args
@@ -26,7 +26,7 @@ def __init__(self, *args):
2626
if not args:
2727
args = ("Commit cannot be completed since the group has already"
2828
" rebalanced and assigned the partitions to another member.",)
29-
super(CommitFailedError, self).__init__(*args)
29+
super().__init__(*args)
3030

3131

3232
class IllegalArgumentError(KafkaError):
@@ -113,7 +113,7 @@ def __str__(self):
113113
"""Add errno to standard KafkaError str"""
114114
return '[Error {0}] {1}'.format(
115115
self.errno,
116-
super(BrokerResponseError, self).__str__())
116+
super().__str__())
117117

118118

119119
class AuthorizationError(BrokerResponseError):

kafka/producer/future.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77

88
class FutureProduceResult(Future):
99
def __init__(self, topic_partition):
10-
super(FutureProduceResult, self).__init__()
10+
super().__init__()
1111
self.topic_partition = topic_partition
1212
self._latch = threading.Event()
1313

1414
def success(self, value):
15-
ret = super(FutureProduceResult, self).success(value)
15+
ret = super().success(value)
1616
self._latch.set()
1717
return ret
1818

1919
def failure(self, error):
20-
ret = super(FutureProduceResult, self).failure(error)
20+
ret = super().failure(error)
2121
self._latch.set()
2222
return ret
2323

@@ -28,7 +28,7 @@ def wait(self, timeout=None):
2828

2929
class FutureRecordMetadata(Future):
3030
def __init__(self, produce_future, batch_index, timestamp_ms, checksum, serialized_key_size, serialized_value_size, serialized_header_size):
31-
super(FutureRecordMetadata, self).__init__()
31+
super().__init__()
3232
self._produce_future = produce_future
3333
# packing args as a tuple is a minor speed optimization
3434
self.args = (batch_index, timestamp_ms, checksum, serialized_key_size, serialized_value_size, serialized_header_size)

kafka/producer/sender.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Sender(threading.Thread):
4242
}
4343

4444
def __init__(self, client, metadata, accumulator, **configs):
45-
super(Sender, self).__init__()
45+
super().__init__()
4646
self.config = copy.copy(self.DEFAULT_CONFIG)
4747
for key in self.config:
4848
if key in configs:

kafka/producer/transaction_manager.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ def exception(self):
524524
return self._error
525525

526526

527-
class TxnRequestHandler(object, metaclass=abc.ABCMeta):
527+
class TxnRequestHandler(metaclass=abc.ABCMeta):
528528
def __init__(self, transaction_manager, result=None):
529529
self.transaction_manager = transaction_manager
530530
self.retry_backoff_ms = transaction_manager.retry_backoff_ms
@@ -612,7 +612,7 @@ def priority(self):
612612

613613
class InitProducerIdHandler(TxnRequestHandler):
614614
def __init__(self, transaction_manager, transaction_timeout_ms):
615-
super(InitProducerIdHandler, self).__init__(transaction_manager)
615+
super().__init__(transaction_manager)
616616

617617
if transaction_manager._api_version >= (2, 0):
618618
version = 1
@@ -645,7 +645,7 @@ def handle_response(self, response):
645645

646646
class AddPartitionsToTxnHandler(TxnRequestHandler):
647647
def __init__(self, transaction_manager, topic_partitions):
648-
super(AddPartitionsToTxnHandler, self).__init__(transaction_manager)
648+
super().__init__(transaction_manager)
649649

650650
if transaction_manager._api_version >= (2, 7):
651651
version = 2
@@ -740,7 +740,7 @@ def maybe_override_retry_backoff_ms(self):
740740

741741
class FindCoordinatorHandler(TxnRequestHandler):
742742
def __init__(self, transaction_manager, coord_type, coord_key):
743-
super(FindCoordinatorHandler, self).__init__(transaction_manager)
743+
super().__init__(transaction_manager)
744744

745745
self._coord_type = coord_type
746746
self._coord_key = coord_key
@@ -796,7 +796,7 @@ def handle_response(self, response):
796796

797797
class EndTxnHandler(TxnRequestHandler):
798798
def __init__(self, transaction_manager, committed):
799-
super(EndTxnHandler, self).__init__(transaction_manager)
799+
super().__init__(transaction_manager)
800800

801801
if self.transaction_manager._api_version >= (2, 7):
802802
version = 2
@@ -837,7 +837,7 @@ def handle_response(self, response):
837837

838838
class AddOffsetsToTxnHandler(TxnRequestHandler):
839839
def __init__(self, transaction_manager, consumer_group_id, offsets):
840-
super(AddOffsetsToTxnHandler, self).__init__(transaction_manager)
840+
super().__init__(transaction_manager)
841841

842842
self.consumer_group_id = consumer_group_id
843843
self.offsets = offsets
@@ -887,7 +887,7 @@ def handle_response(self, response):
887887

888888
class TxnOffsetCommitHandler(TxnRequestHandler):
889889
def __init__(self, transaction_manager, consumer_group_id, offsets, result):
890-
super(TxnOffsetCommitHandler, self).__init__(transaction_manager, result=result)
890+
super().__init__(transaction_manager, result=result)
891891

892892
self.consumer_group_id = consumer_group_id
893893
self.offsets = offsets

0 commit comments

Comments
 (0)