Skip to content

Commit 6299a8a

Browse files
committed
remove py27-isms
1 parent 68a0d8f commit 6299a8a

File tree

11 files changed

+60
-58
lines changed

11 files changed

+60
-58
lines changed

src/hpack/__init__.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,23 @@
88
from .hpack import Encoder, Decoder
99
from .struct import HeaderTuple, NeverIndexedHeaderTuple
1010
from .exceptions import (
11-
HPACKError, HPACKDecodingError, InvalidTableIndex, OversizedHeaderListError, InvalidTableSizeError
11+
HPACKError,
12+
HPACKDecodingError,
13+
InvalidTableIndex,
14+
OversizedHeaderListError,
15+
InvalidTableSizeError
1216
)
1317

1418
__all__ = [
15-
'Encoder', 'Decoder', 'HPACKError', 'HPACKDecodingError',
16-
'InvalidTableIndex', 'HeaderTuple', 'NeverIndexedHeaderTuple',
17-
'OversizedHeaderListError', 'InvalidTableSizeError'
19+
'Encoder',
20+
'Decoder',
21+
'HeaderTuple',
22+
'NeverIndexedHeaderTuple',
23+
'HPACKError',
24+
'HPACKDecodingError',
25+
'InvalidTableIndex',
26+
'OversizedHeaderListError',
27+
'InvalidTableSizeError',
1828
]
1929

2030
__version__ = '4.0.0+dev'

src/hpack/hpack.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def _to_bytes(string):
154154
return string if isinstance(string, bytes) else string.encode('utf-8')
155155

156156

157-
class Encoder(object):
157+
class Encoder:
158158
"""
159159
An HPACK encoder object. This object takes HTTP headers and emits encoded
160160
HTTP/2 header blocks.
@@ -371,7 +371,7 @@ def _encode_table_size_change(self):
371371
return block
372372

373373

374-
class Decoder(object):
374+
class Decoder:
375375
"""
376376
An HPACK decoder object.
377377

src/hpack/huffman.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from .compat import to_byte, decode_hex
1010

1111

12-
class HuffmanEncoder(object):
12+
class HuffmanEncoder:
1313
"""
1414
Encodes a string according to the Huffman encoding table defined in the
1515
HPACK specification.

src/hpack/struct.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class HeaderTuple(tuple):
2525

2626
indexable = True
2727

28-
def __new__(_cls, *args):
29-
return tuple.__new__(_cls, args)
28+
def __new__(cls, *args):
29+
return tuple.__new__(cls, args)
3030

3131

3232
class NeverIndexedHeaderTuple(HeaderTuple):

src/hpack/table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def table_entry_size(name, value):
2323
return 32 + len(name) + len(value)
2424

2525

26-
class HeaderTable(object):
26+
class HeaderTable:
2727
"""
2828
Implements the combined static and dynamic header table
2929

test/test_encode_decode.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
from hypothesis import given
88
from hypothesis.strategies import integers, binary, one_of
99

10+
from hpack import HPACKDecodingError
1011
from hpack.hpack import encode_integer, decode_integer
11-
from hpack.exceptions import HPACKDecodingError
1212

1313

14-
class TestIntegerEncoding(object):
14+
class TestIntegerEncoding:
1515
# These tests are stolen from the HPACK spec.
1616
def test_encoding_10_with_5_bit_prefix(self):
1717
val = encode_integer(10, 5)
@@ -29,7 +29,7 @@ def test_encoding_42_with_8_bit_prefix(self):
2929
assert val == bytearray(b'\x2a')
3030

3131

32-
class TestIntegerDecoding(object):
32+
class TestIntegerDecoding:
3333
# These tests are stolen from the HPACK spec.
3434
def test_decoding_10_with_5_bit_prefix(self):
3535
val = decode_integer(b'\x0a', 5)
@@ -52,7 +52,7 @@ def test_decode_insufficient_data_fails(self):
5252
decode_integer(b'\x1f', 5)
5353

5454

55-
class TestEncodingProperties(object):
55+
class TestEncodingProperties:
5656
"""
5757
Property-based tests for our integer encoder and decoder.
5858
"""

test/test_hpack.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
# -*- coding: utf-8 -*-
2-
from hpack.hpack import Encoder, Decoder, _dict_to_iterable, _to_bytes
3-
from hpack.exceptions import (
4-
HPACKDecodingError, InvalidTableIndex, OversizedHeaderListError,
5-
InvalidTableSizeError
6-
)
7-
from hpack.struct import HeaderTuple, NeverIndexedHeaderTuple
82
import itertools
93
import pytest
104

115
from hypothesis import given
126
from hypothesis.strategies import text, binary, sets, one_of
137

8+
from hpack import (
9+
Encoder,
10+
Decoder,
11+
HeaderTuple,
12+
NeverIndexedHeaderTuple,
13+
HPACKDecodingError,
14+
InvalidTableIndex,
15+
OversizedHeaderListError,
16+
InvalidTableSizeError,
17+
)
18+
from hpack.hpack import _dict_to_iterable, _to_bytes
19+
1420
try:
1521
unicode = unicode
1622
except NameError:
1723
unicode = str
1824

1925

20-
class TestHPACKEncoder(object):
26+
class TestHPACKEncoder:
2127
# These tests are stolen entirely from the IETF specification examples.
2228
def test_literal_header_field_with_indexing(self):
2329
"""
@@ -338,7 +344,7 @@ def test_evicting_header_table_objects(self):
338344
assert len(e.header_table.dynamic_entries) == 1
339345

340346

341-
class TestHPACKDecoder(object):
347+
class TestHPACKDecoder:
342348
# These tests are stolen entirely from the IETF specification examples.
343349
def test_literal_header_field_with_indexing(self):
344350
"""
@@ -737,7 +743,7 @@ def test_truncated_header_value(self):
737743
d.decode(data)
738744

739745

740-
class TestDictToIterable(object):
746+
class TestDictToIterable:
741747
"""
742748
The dict_to_iterable function has some subtle requirements: validates that
743749
everything behaves as expected.

test/test_hpack_integration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
long time to run, so they're outside the main test suite, but they need to be
55
run before every change to HPACK.
66
"""
7-
from hpack.hpack import Decoder, Encoder
8-
from hpack.struct import HeaderTuple
97
from binascii import unhexlify
108
from pytest import skip
119

10+
from hpack import Decoder, Encoder, HeaderTuple
1211

13-
class TestHPACKDecoderIntegration(object):
12+
13+
class TestHPACKDecoderIntegration:
1414
def test_can_decode_a_story(self, story):
1515
d = Decoder()
1616

test/test_huffman.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# -*- coding: utf-8 -*-
2-
from hpack.exceptions import HPACKDecodingError
3-
from hpack.huffman_table import decode_huffman
2+
from hpack import HPACKDecodingError
43
from hpack.huffman import HuffmanEncoder
54
from hpack.huffman_constants import REQUEST_CODES, REQUEST_CODES_LENGTH
5+
from hpack.huffman_table import decode_huffman
66

77
from hypothesis import given, example
88
from hypothesis.strategies import binary
99

1010

11-
class TestHuffman(object):
11+
class TestHuffman:
1212

1313
def test_request_huffman_decoder(self):
1414
assert (
@@ -34,7 +34,7 @@ def test_request_huffman_encode(self):
3434
)
3535

3636

37-
class TestHuffmanDecoder(object):
37+
class TestHuffmanDecoder:
3838
@given(data=binary())
3939
@example(b'\xff')
4040
@example(b'\x5f\xff\xff\xff\xff')

test/test_struct.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
"""
88
import pytest
99

10-
from hpack.struct import HeaderTuple, NeverIndexedHeaderTuple
10+
from hpack import HeaderTuple, NeverIndexedHeaderTuple
1111

1212

13-
class TestHeaderTuple(object):
13+
class TestHeaderTuple:
1414
def test_is_tuple(self):
1515
"""
1616
HeaderTuple objects are tuples.

0 commit comments

Comments
 (0)