Skip to content

Commit f35a1f9

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent fc0b848 commit f35a1f9

3 files changed

Lines changed: 10 additions & 17 deletions

File tree

aiohttp/http_exceptions.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ class ContentLengthError(PayloadEncodingError):
7474

7575

7676
class LineTooLong(BadHttpMessage):
77-
def __init__(
78-
self, line: bytes, limit: int, context: str = "line"
79-
) -> None:
77+
def __init__(self, line: bytes, limit: int, context: str = "line") -> None:
8078
super().__init__(
8179
f"Got more than {limit} bytes when reading {context}: {line!r}."
8280
)

aiohttp/http_parser.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,7 @@ def feed_data(
359359
raise LineTooLong(
360360
line[:100] + b"...",
361361
max_line_length,
362-
"request/status line"
363-
if not self._lines
364-
else "header line",
362+
"request/status line" if not self._lines else "header line",
365363
)
366364

367365
self._lines.append(line)
@@ -936,9 +934,11 @@ def feed_data(
936934
raise LineTooLong(
937935
self._chunk_tail[:100] + b"...",
938936
max_line_length,
939-
"chunk size line"
940-
if self._chunk != ChunkState.PARSE_TRAILERS
941-
else "trailer line",
937+
(
938+
"chunk size line"
939+
if self._chunk != ChunkState.PARSE_TRAILERS
940+
else "trailer line"
941+
),
942942
)
943943

944944
chunk = self._chunk_tail + chunk

tests/test_http_exceptions.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ def test_ctor_with_context(self) -> None:
8686
err = http_exceptions.LineTooLong(b"spam", 10, "request URL")
8787
assert err.code == 400
8888
assert (
89-
err.message
90-
== "Got more than 10 bytes when reading request URL: b'spam'."
89+
err.message == "Got more than 10 bytes when reading request URL: b'spam'."
9190
)
9291
assert err.headers is None
9392

@@ -105,9 +104,7 @@ def test_pickle(self) -> None:
105104
assert err2.foo == "bar"
106105

107106
def test_pickle_with_context(self) -> None:
108-
err = http_exceptions.LineTooLong(
109-
line=b"spam", limit=10, context="request URL"
110-
)
107+
err = http_exceptions.LineTooLong(line=b"spam", limit=10, context="request URL")
111108
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
112109
pickled = pickle.dumps(err, proto)
113110
err2 = pickle.loads(pickled)
@@ -117,9 +114,7 @@ def test_pickle_with_context(self) -> None:
117114

118115
def test_str(self) -> None:
119116
err = http_exceptions.LineTooLong(line=b"spam", limit=10)
120-
expected = (
121-
"400, message:\n Got more than 10 bytes when reading line: b'spam'."
122-
)
117+
expected = "400, message:\n Got more than 10 bytes when reading line: b'spam'."
123118
assert str(err) == expected
124119

125120
def test_repr(self) -> None:

0 commit comments

Comments
 (0)