self.decompressor = brotli.Decompressor()
self.seen_data = False
+ self._decompress: typing.Callable[[bytes], bytes]
if hasattr(self.decompressor, "decompress"):
# The 'brotlicffi' package.
self._decompress = self.decompressor.decompress # pragma: no cover
if content_type is not None:
mime_type, _, _ = content_type.partition(";")
try:
- return pygments.lexers.get_lexer_for_mimetype(mime_type.strip()).name
+ return typing.cast(
+ str, pygments.lexers.get_lexer_for_mimetype(mime_type.strip()).name
+ )
except pygments.util.ClassNotFound: # pragma: no cover
pass
return "" # pragma: no cover
@property
def http_version(self) -> str:
try:
- return self.extensions["http_version"].decode("ascii", errors="ignore")
+ http_version: bytes = self.extensions["http_version"]
except KeyError:
return "HTTP/1.1"
+ else:
+ return http_version.decode("ascii", errors="ignore")
@property
def reason_phrase(self) -> str:
try:
- return self.extensions["reason_phrase"].decode("ascii", errors="ignore")
+ reason_phrase: bytes = self.extensions["reason_phrase"]
except KeyError:
return codes.get_reason_phrase(self.status_code)
+ else:
+ return reason_phrase.decode("ascii", errors="ignore")
@property
def url(self) -> URL:
be properly URL escaped when decoding the parameter names and values themselves.
"""
+ _uri_reference: rfc3986.URIReference
+
def __init__(
self, url: typing.Union["URL", str] = "", **kwargs: typing.Any
) -> None:
return isinstance(other, (URL, str)) and str(self) == str(URL(other))
def __str__(self) -> str:
- return self._uri_reference.unsplit()
+ return typing.cast(str, self._uri_reference.unsplit())
def __repr__(self) -> str:
class_name = self.__class__.__name__
elif library == "curio": # pragma: no cover
import curio
- return await curio.clock()
+ return typing.cast(float, await curio.clock())
import asyncio
warn_redundant_casts = True
strict_concatenate = True
disallow_incomplete_defs = True
+warn_return_any = True
[mypy-tests.*]
disallow_untyped_defs = False
...
```
"""
- return request.param
+ return typing.cast(str, request.param)
@pytest.fixture(scope="function", autouse=True)
@pytest.mark.asyncio
async def test_async_bytesio_content():
class AsyncBytesIO:
- def __init__(self, content):
+ def __init__(self, content: bytes):
self._idx = 0
self._content = content