Skip to content

Commit 27e8a86

Browse files
committed
lint++
1 parent 9a54234 commit 27e8a86

10 files changed

+211
-158
lines changed

CHANGELOG.rst

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ dev
99
- Support for Python 3.6 has been removed.
1010
- Support for Python 3.7 has been removed.
1111
- Support for Python 3.8 has been removed.
12+
- Renamed `InvalidTableIndex` exception to `InvalidTableIndexError`.
1213

1314
**API Changes (Backward Compatible)**
1415

docs/source/api.rst

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ This document provides the HPACK API.
1919

2020
.. autoclass:: hpack.HPACKDecodingError
2121

22+
.. autoclass:: hpack.InvalidTableIndexError
23+
2224
.. autoclass:: hpack.InvalidTableIndex
2325

2426
.. autoclass:: hpack.OversizedHeaderListError

pyproject.toml

+37-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ testing = [
6262
linting = [
6363
"ruff>=0.8.0,<1",
6464
"mypy>=1.13.0,<2",
65+
"typing_extensions>=4.12.2",
6566
]
6667

6768
packaging = [
@@ -86,8 +87,43 @@ hpack = [ "py.typed" ]
8687
version = { attr = "hpack.__version__" }
8788

8889
[tool.ruff]
89-
line-length = 140
90+
line-length = 150
9091
target-version = "py39"
92+
format.preview = true
93+
format.docstring-code-line-length = 100
94+
format.docstring-code-format = true
95+
lint.select = [
96+
"ALL",
97+
]
98+
lint.ignore = [
99+
"ANN401", # kwargs with typing.Any
100+
"CPY", # not required
101+
"D101", # docs readability
102+
"D102", # docs readability
103+
"D105", # docs readability
104+
"D107", # docs readability
105+
"D200", # docs readability
106+
"D205", # docs readability
107+
"D205", # docs readability
108+
"D203", # docs readability
109+
"D212", # docs readability
110+
"D400", # docs readability
111+
"D401", # docs readability
112+
"D415", # docs readability
113+
"PLR2004", # readability
114+
"SIM108", # readability
115+
"RUF012", # readability
116+
"FBT001", # readability
117+
"FBT002", # readability
118+
"PGH003", # readability
119+
"PGH004", # readability
120+
"PYI034", # PEP 673 not yet available in Python 3.9 - only in 3.11+
121+
]
122+
lint.isort.required-imports = [ "from __future__ import annotations" ]
123+
124+
[tool.mypy]
125+
show_error_codes = true
126+
strict = true
91127

92128
[tool.pytest.ini_options]
93129
testpaths = [ "tests" ]

src/hpack/__init__.py

+15-21
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
11
"""
2-
hpack
3-
~~~~~
4-
52
HTTP/2 header encoding for Python.
63
"""
7-
from .hpack import Encoder, Decoder
4+
from __future__ import annotations
5+
6+
from .exceptions import HPACKDecodingError, HPACKError, InvalidTableIndex, InvalidTableIndexError, InvalidTableSizeError, OversizedHeaderListError
7+
from .hpack import Decoder, Encoder
88
from .struct import HeaderTuple, NeverIndexedHeaderTuple
9-
from .exceptions import (
10-
HPACKError,
11-
HPACKDecodingError,
12-
InvalidTableIndex,
13-
OversizedHeaderListError,
14-
InvalidTableSizeError
15-
)
169

1710
__all__ = [
18-
'Encoder',
19-
'Decoder',
20-
'HeaderTuple',
21-
'NeverIndexedHeaderTuple',
22-
'HPACKError',
23-
'HPACKDecodingError',
24-
'InvalidTableIndex',
25-
'OversizedHeaderListError',
26-
'InvalidTableSizeError',
11+
"Decoder",
12+
"Encoder",
13+
"HPACKDecodingError",
14+
"HPACKError",
15+
"HeaderTuple",
16+
"InvalidTableIndex",
17+
"InvalidTableIndexError",
18+
"InvalidTableSizeError",
19+
"NeverIndexedHeaderTuple",
20+
"OversizedHeaderListError",
2721
]
2822

29-
__version__ = '4.1.0+dev'
23+
__version__ = "4.1.0+dev"

src/hpack/exceptions.py

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
11
"""
2-
hyper/http20/exceptions
3-
~~~~~~~~~~~~~~~~~~~~~~~
4-
5-
This defines exceptions used in the HTTP/2 portion of hyper.
2+
Exceptions used in hpack.
63
"""
4+
from __future__ import annotations
75

86

97
class HPACKError(Exception):
108
"""
119
The base class for all ``hpack`` exceptions.
1210
"""
13-
pass
11+
1412

1513

1614
class HPACKDecodingError(HPACKError):
1715
"""
1816
An error has been encountered while performing HPACK decoding.
1917
"""
20-
pass
2118

2219

23-
class InvalidTableIndex(HPACKDecodingError):
20+
21+
class InvalidTableIndexError(HPACKDecodingError):
2422
"""
2523
An invalid table index was received.
24+
25+
.. versionadded:: 4.1.0
26+
"""
27+
28+
class InvalidTableIndex(InvalidTableIndexError): # noqa: N818
29+
"""
30+
An invalid table index was received.
31+
32+
.. deprecated:: 4.1.0
33+
Renamed to :class:`InvalidTableIndexError`, use it instead.
2634
"""
27-
pass
2835

2936

3037
class OversizedHeaderListError(HPACKDecodingError):
@@ -34,7 +41,6 @@ class OversizedHeaderListError(HPACKDecodingError):
3441
3542
.. versionadded:: 2.3.0
3643
"""
37-
pass
3844

3945

4046
class InvalidTableSizeError(HPACKDecodingError):
@@ -45,4 +51,3 @@ class InvalidTableSizeError(HPACKDecodingError):
4551
4652
.. versionadded:: 3.0.0
4753
"""
48-
pass

0 commit comments

Comments
 (0)