Skip to content

Commit

Permalink
lint++
Browse files Browse the repository at this point in the history
  • Loading branch information
Kriechi committed Dec 21, 2024
1 parent 9a54234 commit 27e8a86
Show file tree
Hide file tree
Showing 10 changed files with 211 additions and 158 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dev
- Support for Python 3.6 has been removed.
- Support for Python 3.7 has been removed.
- Support for Python 3.8 has been removed.
- Renamed `InvalidTableIndex` exception to `InvalidTableIndexError`.

**API Changes (Backward Compatible)**

Expand Down
2 changes: 2 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ This document provides the HPACK API.

.. autoclass:: hpack.HPACKDecodingError

.. autoclass:: hpack.InvalidTableIndexError

.. autoclass:: hpack.InvalidTableIndex

.. autoclass:: hpack.OversizedHeaderListError
Expand Down
38 changes: 37 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ testing = [
linting = [
"ruff>=0.8.0,<1",
"mypy>=1.13.0,<2",
"typing_extensions>=4.12.2",
]

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

[tool.ruff]
line-length = 140
line-length = 150
target-version = "py39"
format.preview = true
format.docstring-code-line-length = 100
format.docstring-code-format = true
lint.select = [
"ALL",
]
lint.ignore = [
"ANN401", # kwargs with typing.Any
"CPY", # not required
"D101", # docs readability
"D102", # docs readability
"D105", # docs readability
"D107", # docs readability
"D200", # docs readability
"D205", # docs readability
"D205", # docs readability
"D203", # docs readability
"D212", # docs readability
"D400", # docs readability
"D401", # docs readability
"D415", # docs readability
"PLR2004", # readability
"SIM108", # readability
"RUF012", # readability
"FBT001", # readability
"FBT002", # readability
"PGH003", # readability
"PGH004", # readability
"PYI034", # PEP 673 not yet available in Python 3.9 - only in 3.11+
]
lint.isort.required-imports = [ "from __future__ import annotations" ]

[tool.mypy]
show_error_codes = true
strict = true

[tool.pytest.ini_options]
testpaths = [ "tests" ]
Expand Down
36 changes: 15 additions & 21 deletions src/hpack/__init__.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
"""
hpack
~~~~~
HTTP/2 header encoding for Python.
"""
from .hpack import Encoder, Decoder
from __future__ import annotations

from .exceptions import HPACKDecodingError, HPACKError, InvalidTableIndex, InvalidTableIndexError, InvalidTableSizeError, OversizedHeaderListError
from .hpack import Decoder, Encoder
from .struct import HeaderTuple, NeverIndexedHeaderTuple
from .exceptions import (
HPACKError,
HPACKDecodingError,
InvalidTableIndex,
OversizedHeaderListError,
InvalidTableSizeError
)

__all__ = [
'Encoder',
'Decoder',
'HeaderTuple',
'NeverIndexedHeaderTuple',
'HPACKError',
'HPACKDecodingError',
'InvalidTableIndex',
'OversizedHeaderListError',
'InvalidTableSizeError',
"Decoder",
"Encoder",
"HPACKDecodingError",
"HPACKError",
"HeaderTuple",
"InvalidTableIndex",
"InvalidTableIndexError",
"InvalidTableSizeError",
"NeverIndexedHeaderTuple",
"OversizedHeaderListError",
]

__version__ = '4.1.0+dev'
__version__ = "4.1.0+dev"
25 changes: 15 additions & 10 deletions src/hpack/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
"""
hyper/http20/exceptions
~~~~~~~~~~~~~~~~~~~~~~~
This defines exceptions used in the HTTP/2 portion of hyper.
Exceptions used in hpack.
"""
from __future__ import annotations


class HPACKError(Exception):
"""
The base class for all ``hpack`` exceptions.
"""
pass



class HPACKDecodingError(HPACKError):
"""
An error has been encountered while performing HPACK decoding.
"""
pass


class InvalidTableIndex(HPACKDecodingError):

class InvalidTableIndexError(HPACKDecodingError):
"""
An invalid table index was received.
.. versionadded:: 4.1.0
"""

class InvalidTableIndex(InvalidTableIndexError): # noqa: N818
"""
An invalid table index was received.
.. deprecated:: 4.1.0
Renamed to :class:`InvalidTableIndexError`, use it instead.
"""
pass


class OversizedHeaderListError(HPACKDecodingError):
Expand All @@ -34,7 +41,6 @@ class OversizedHeaderListError(HPACKDecodingError):
.. versionadded:: 2.3.0
"""
pass


class InvalidTableSizeError(HPACKDecodingError):
Expand All @@ -45,4 +51,3 @@ class InvalidTableSizeError(HPACKDecodingError):
.. versionadded:: 3.0.0
"""
pass
Loading

0 comments on commit 27e8a86

Please sign in to comment.