Skip to content

Commit 835d52f

Browse files
committed
fix lint
1 parent d4e976b commit 835d52f

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

hishel/beta/_core/_headers.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def http_unquote(raw: str) -> tuple[int, str]:
218218
if not raw or raw[0] != '"':
219219
return -1, ""
220220

221-
buf = []
221+
buf: list[str] = []
222222
i = 1 # Start after opening quote
223223

224224
while i < len(raw):
@@ -359,7 +359,7 @@ class CacheControl:
359359
- List[str]: directive present with specific field names
360360
"""
361361

362-
def __init__(self):
362+
def __init__(self) -> None:
363363
# Common directives
364364
self.max_age: Optional[int] = None
365365
self.no_store: bool = False
@@ -590,7 +590,7 @@ def handle_directive_without_value(cc: CacheControl, token: str) -> None:
590590
cc.extensions.append(token)
591591

592592

593-
def parse_cache_control(value: str) -> CacheControl:
593+
def parse_cache_control(value: str | None) -> CacheControl:
594594
"""
595595
Parse a Cache-Control header from either a request or response.
596596
@@ -631,4 +631,6 @@ def parse_cache_control(value: str) -> CacheControl:
631631
>>> cc.stale_while_revalidate
632632
86400
633633
"""
634+
if value is None:
635+
return CacheControl()
634636
return parse(value)

tests/beta/_core/test_headers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,14 @@ def test_no_cache_with_multiple_fields(self):
169169
def test_no_cache_field_canonicalization(self):
170170
"""Field names should be canonicalized to Title-Case."""
171171
cc = parse_cache_control('no-cache="set-cookie, authorization"')
172+
assert isinstance(cc.no_cache, list)
172173
assert "Set-Cookie" in cc.no_cache
173174
assert "Authorization" in cc.no_cache
174175

175176
def test_no_cache_with_whitespace(self):
176177
"""no-cache with whitespace around field names."""
177178
cc = parse_cache_control('no-cache=" Set-Cookie , Authorization "')
179+
assert isinstance(cc.no_cache, list)
178180
assert "Set-Cookie" in cc.no_cache
179181
assert "Authorization" in cc.no_cache
180182

@@ -203,6 +205,7 @@ def test_private_with_multiple_fields(self):
203205
def test_private_field_canonicalization(self):
204206
"""Field names should be canonicalized."""
205207
cc = parse_cache_control('private="x-custom-header"')
208+
assert isinstance(cc.private, list)
206209
assert "X-Custom-Header" in cc.private
207210

208211

@@ -308,6 +311,7 @@ class TestQuotedValues:
308311
def test_quoted_field_names(self):
309312
"""Quoted field names in no-cache."""
310313
cc = parse_cache_control('no-cache="Set-Cookie"')
314+
assert isinstance(cc.no_cache, list)
311315
assert "Set-Cookie" in cc.no_cache
312316

313317
def test_quoted_extension_value(self):

0 commit comments

Comments
 (0)