Skip to content

Commit 4e068f4

Browse files
Kriechipgjones
authored andcommitted
remove py27-isms
1 parent ed7d684 commit 4e068f4

File tree

4 files changed

+30
-35
lines changed

4 files changed

+30
-35
lines changed

hyperframe/flags.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@
66
Defines basic Flag and Flags data structures.
77
"""
88
import collections
9-
10-
try:
11-
from collections.abc import MutableSet
12-
except ImportError: # pragma: no cover
13-
# Python 2.7 compatibility
14-
from collections import MutableSet
9+
from collections.abc import MutableSet
1510

1611
Flag = collections.namedtuple("Flag", ["name", "bit"])
1712

hyperframe/frame.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
_STRUCT_B = struct.Struct(">B")
3939

4040

41-
class Frame(object):
41+
class Frame:
4242
"""
4343
The base class for all HTTP/2 frames.
4444
"""
@@ -175,13 +175,13 @@ def parse_body(self, data):
175175
raise NotImplementedError()
176176

177177

178-
class Padding(object):
178+
class Padding:
179179
"""
180180
Mixin for frames that contain padding. Defines extra fields that can be
181181
used and set by frames that can be padded.
182182
"""
183183
def __init__(self, stream_id, pad_length=0, **kwargs):
184-
super(Padding, self).__init__(stream_id, **kwargs)
184+
super().__init__(stream_id, **kwargs)
185185

186186
#: The length of the padding to use.
187187
self.pad_length = pad_length
@@ -212,7 +212,7 @@ def total_padding(self): # pragma: no cover
212212
return self.pad_length
213213

214214

215-
class Priority(object):
215+
class Priority:
216216
"""
217217
Mixin for frames that contain priority data. Defines extra fields that can
218218
be used and set by frames that contain priority data.
@@ -223,7 +223,7 @@ def __init__(self,
223223
stream_weight=0x0,
224224
exclusive=False,
225225
**kwargs):
226-
super(Priority, self).__init__(stream_id, **kwargs)
226+
super().__init__(stream_id, **kwargs)
227227

228228
#: The stream ID of the stream on which this stream depends.
229229
self.depends_on = depends_on
@@ -269,7 +269,7 @@ class DataFrame(Padding, Frame):
269269
stream_association = _STREAM_ASSOC_HAS_STREAM
270270

271271
def __init__(self, stream_id, data=b'', **kwargs):
272-
super(DataFrame, self).__init__(stream_id, **kwargs)
272+
super().__init__(stream_id, **kwargs)
273273

274274
#: The data contained on this frame.
275275
self.data = data
@@ -351,7 +351,7 @@ class RstStreamFrame(Frame):
351351
stream_association = _STREAM_ASSOC_HAS_STREAM
352352

353353
def __init__(self, stream_id, error_code=0, **kwargs):
354-
super(RstStreamFrame, self).__init__(stream_id, **kwargs)
354+
super().__init__(stream_id, **kwargs)
355355

356356
#: The error code used when resetting the stream.
357357
self.error_code = error_code
@@ -412,7 +412,7 @@ class SettingsFrame(Frame):
412412
ENABLE_CONNECT_PROTOCOL = 0x08
413413

414414
def __init__(self, stream_id=0, settings=None, **kwargs):
415-
super(SettingsFrame, self).__init__(stream_id, **kwargs)
415+
super().__init__(stream_id, **kwargs)
416416

417417
if settings and "ACK" in kwargs.get("flags", ()):
418418
raise InvalidFrameError(
@@ -463,7 +463,7 @@ class PushPromiseFrame(Padding, Frame):
463463
stream_association = _STREAM_ASSOC_HAS_STREAM
464464

465465
def __init__(self, stream_id, promised_stream_id=0, data=b'', **kwargs):
466-
super(PushPromiseFrame, self).__init__(stream_id, **kwargs)
466+
super().__init__(stream_id, **kwargs)
467467

468468
#: The stream ID that is promised by this frame.
469469
self.promised_stream_id = promised_stream_id
@@ -518,7 +518,7 @@ class PingFrame(Frame):
518518
stream_association = _STREAM_ASSOC_NO_STREAM
519519

520520
def __init__(self, stream_id=0, opaque_data=b'', **kwargs):
521-
super(PingFrame, self).__init__(stream_id, **kwargs)
521+
super().__init__(stream_id, **kwargs)
522522

523523
#: The opaque data sent in this PING frame, as a bytestring.
524524
self.opaque_data = opaque_data
@@ -565,7 +565,7 @@ def __init__(self,
565565
error_code=0,
566566
additional_data=b'',
567567
**kwargs):
568-
super(GoAwayFrame, self).__init__(stream_id, **kwargs)
568+
super().__init__(stream_id, **kwargs)
569569

570570
#: The last stream ID definitely seen by the remote peer.
571571
self.last_stream_id = last_stream_id
@@ -621,7 +621,7 @@ class WindowUpdateFrame(Frame):
621621
stream_association = _STREAM_ASSOC_EITHER
622622

623623
def __init__(self, stream_id, window_increment=0, **kwargs):
624-
super(WindowUpdateFrame, self).__init__(stream_id, **kwargs)
624+
super().__init__(stream_id, **kwargs)
625625

626626
#: The amount the flow control window is to be incremented.
627627
self.window_increment = window_increment
@@ -675,7 +675,7 @@ class HeadersFrame(Padding, Priority, Frame):
675675
stream_association = _STREAM_ASSOC_HAS_STREAM
676676

677677
def __init__(self, stream_id, data=b'', **kwargs):
678-
super(HeadersFrame, self).__init__(stream_id, **kwargs)
678+
super().__init__(stream_id, **kwargs)
679679

680680
#: The HPACK-encoded header block.
681681
self.data = data
@@ -728,7 +728,7 @@ class ContinuationFrame(Frame):
728728
stream_association = _STREAM_ASSOC_HAS_STREAM
729729

730730
def __init__(self, stream_id, data=b'', **kwargs):
731-
super(ContinuationFrame, self).__init__(stream_id, **kwargs)
731+
super().__init__(stream_id, **kwargs)
732732

733733
#: The HPACK-encoded header block.
734734
self.data = data
@@ -761,7 +761,7 @@ class AltSvcFrame(Frame):
761761
stream_association = _STREAM_ASSOC_EITHER
762762

763763
def __init__(self, stream_id, origin=b'', field=b'', **kwargs):
764-
super(AltSvcFrame, self).__init__(stream_id, **kwargs)
764+
super().__init__(stream_id, **kwargs)
765765

766766
if not isinstance(origin, bytes):
767767
raise InvalidFrameError("AltSvc origin must be bytestring.")
@@ -808,7 +808,7 @@ class ExtensionFrame(Frame):
808808
stream_association = _STREAM_ASSOC_EITHER
809809

810810
def __init__(self, type, stream_id, **kwargs):
811-
super(ExtensionFrame, self).__init__(stream_id, **kwargs)
811+
super().__init__(stream_id, **kwargs)
812812
self.type = type
813813
self.flag_byte = None
814814

test/test_flags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66

77

8-
class TestFlags(object):
8+
class TestFlags:
99
def test_add(self):
1010
flags = Flags([Flag("VALID_FLAG", 0x00)])
1111
assert not flags

test/test_frames.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def decode_frame(frame_data):
1717
return f
1818

1919

20-
class TestGeneralFrameBehaviour(object):
20+
class TestGeneralFrameBehaviour:
2121
def test_base_frame_ignores_flags(self):
2222
f = Frame(stream_id=0)
2323
flags = f.parse_flags(0xFF)
@@ -100,7 +100,7 @@ def test_cannot_parse_invalid_frame_header(self):
100100
Frame.parse_frame_header(b'\x00\x00\x08\x00\x01\x00\x00\x00')
101101

102102

103-
class TestDataFrame(object):
103+
class TestDataFrame:
104104
payload = b'\x00\x00\x08\x00\x01\x00\x00\x00\x01testdata'
105105
payload_with_padding = (
106106
b'\x00\x00\x13\x00\x09\x00\x00\x00\x01\x0Atestdata' + b'\0' * 10
@@ -228,7 +228,7 @@ def test_data_frame_with_no_length_parses(self):
228228
assert new_frame.data == b''
229229

230230

231-
class TestPriorityFrame(object):
231+
class TestPriorityFrame:
232232
payload = b'\x00\x00\x05\x02\x00\x00\x00\x00\x01\x80\x00\x00\x04\x40'
233233

234234
def test_priority_frame_has_no_flags(self):
@@ -277,7 +277,7 @@ def test_short_priority_frame_errors(self):
277277
decode_frame(self.payload[:-2])
278278

279279

280-
class TestRstStreamFrame(object):
280+
class TestRstStreamFrame:
281281
def test_rst_stream_frame_has_no_flags(self):
282282
f = RstStreamFrame(1)
283283
flags = f.parse_flags(0xFF)
@@ -310,7 +310,7 @@ def test_rst_stream_frame_must_have_body_length_four(self):
310310
f.parse_body(b'\x01')
311311

312312

313-
class TestSettingsFrame(object):
313+
class TestSettingsFrame:
314314
serialized = (
315315
b'\x00\x00\x2A\x04\x01\x00\x00\x00\x00' + # Frame header
316316
b'\x00\x01\x00\x00\x10\x00' + # HEADER_TABLE_SIZE
@@ -390,7 +390,7 @@ def test_short_settings_frame_errors(self):
390390
decode_frame(self.serialized[:-2])
391391

392392

393-
class TestPushPromiseFrame(object):
393+
class TestPushPromiseFrame:
394394
def test_push_promise_frame_flags(self):
395395
f = PushPromiseFrame(1)
396396
flags = f.parse_flags(0xFF)
@@ -475,7 +475,7 @@ def test_short_push_promise_errors(self):
475475
decode_frame(s)
476476

477477

478-
class TestPingFrame(object):
478+
class TestPingFrame:
479479
def test_ping_frame_has_only_one_flag(self):
480480
f = PingFrame()
481481
flags = f.parse_flags(0xFF)
@@ -527,7 +527,7 @@ def test_ping_frame_has_no_less_than_body_length_8(self):
527527
f.parse_body(b'\x01\x02\x03\x04\x05\x06\x07')
528528

529529

530-
class TestGoAwayFrame(object):
530+
class TestGoAwayFrame:
531531
def test_go_away_has_no_flags(self):
532532
f = GoAwayFrame()
533533
flags = f.parse_flags(0xFF)
@@ -590,7 +590,7 @@ def test_short_goaway_frame_errors(self):
590590
decode_frame(s)
591591

592592

593-
class TestWindowUpdateFrame(object):
593+
class TestWindowUpdateFrame:
594594
def test_window_update_has_no_flags(self):
595595
f = WindowUpdateFrame(0)
596596
flags = f.parse_flags(0xFF)
@@ -630,7 +630,7 @@ def test_short_windowupdate_frame_errors(self):
630630
decode_frame(WindowUpdateFrame(2**31).serialize())
631631

632632

633-
class TestHeadersFrame(object):
633+
class TestHeadersFrame:
634634
def test_headers_frame_flags(self):
635635
f = HeadersFrame(1)
636636
flags = f.parse_flags(0xFF)
@@ -712,7 +712,7 @@ def test_headers_frame_with_no_length_parses(self):
712712
assert new_frame.data == b''
713713

714714

715-
class TestContinuationFrame(object):
715+
class TestContinuationFrame:
716716
def test_continuation_frame_flags(self):
717717
f = ContinuationFrame(1)
718718
flags = f.parse_flags(0xFF)
@@ -740,7 +740,7 @@ def test_continuation_frame_parses_properly(self):
740740
assert f.body_len == 11
741741

742742

743-
class TestAltSvcFrame(object):
743+
class TestAltSvcFrame:
744744
payload_with_origin = (
745745
b'\x00\x00\x31' # Length
746746
b'\x0A' # Type

0 commit comments

Comments
 (0)