Skip to content
Myr

Typing: enable warn_return_any (#2477)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Martijn Pieters · committed by GitHub · parent 0eb97fc · Browse files · 8 files+17 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

8 files+17 added−7 removed

  • tests:+2 added−2 removed
  • other:+15 added−5 removed

8 files+17 added−7 removed

modified:httpx/_decoders.py+1 added
102 unmodified lines
103 ) from None104105 self.decompressor = brotli.Decompressor()106 self.seen_data = False107 self._decompress: typing.Callable[[bytes], bytes]108 if hasattr(self.decompressor, "decompress"):109 # The 'brotlicffi' package.110 self._decompress = self.decompressor.decompress # pragma: no cover111 else:
223 unmodified lines
modified:httpx/_main.py+3 added-1 removed
98 unmodified lines
99 content_type = response.headers.get("Content-Type")100 if content_type is not None:101 mime_type, _, _ = content_type.partition(";")102 try:103 return typing.cast(103 return pygments.lexers.get_lexer_for_mimetype(mime_type.strip()).name104 str, pygments.lexers.get_lexer_for_mimetype(mime_type.strip()).name105 )106 except pygments.util.ClassNotFound: # pragma: no cover107 pass108 return "" # pragma: no cover109
397 unmodified lines
modified:httpx/_models.py+6 added-2 removed
538 unmodified lines
539540 @property541 def http_version(self) -> str:542 try:543 return self.extensions["http_version"].decode("ascii", errors="ignore")543 http_version: bytes = self.extensions["http_version"]544 except KeyError:545 return "HTTP/1.1"546 else:547 return http_version.decode("ascii", errors="ignore")548549 @property550 def reason_phrase(self) -> str:551 try:550 return self.extensions["reason_phrase"].decode("ascii", errors="ignore")552 reason_phrase: bytes = self.extensions["reason_phrase"]553 except KeyError:554 return codes.get_reason_phrase(self.status_code)555 else:556 return reason_phrase.decode("ascii", errors="ignore")557558 @property559 def url(self) -> URL:560 """
649 unmodified lines
modified:httpx/_urls.py+3 added-1 removed
68 unmodified lines
69 * `url.query` is raw bytes, without URL escaping. A URL query string portion can only70 be properly URL escaped when decoding the parameter names and values themselves.71 """7273 _uri_reference: rfc3986.URIReference7475 def __init__(76 self, url: typing.Union["URL", str] = "", **kwargs: typing.Any77 ) -> None:78 if isinstance(url, str):
429 unmodified lines
508 def __eq__(self, other: typing.Any) -> bool:509 return isinstance(other, (URL, str)) and str(self) == str(URL(other))510511 def __str__(self) -> str:510 return self._uri_reference.unsplit()512 return typing.cast(str, self._uri_reference.unsplit())513514 def __repr__(self) -> str:515 class_name = self.__class__.__name__516 url_str = str(self)
237 unmodified lines
modified:httpx/_utils.py+1 added-1 removed
399 unmodified lines
400 return trio.current_time()401 elif library == "curio": # pragma: no cover402 import curio403404 return await curio.clock()404 return typing.cast(float, await curio.clock())405406 import asyncio407408 return asyncio.get_event_loop().time()
123 unmodified lines
modified:tests/conftest.py+1 added-1 removed
50 unmodified lines
51 async def my_async_test():52 ...53 ```54 """55 return request.param55 return typing.cast(str, request.param)565758@pytest.fixture(scope="function", autouse=True)59def clean_environ():
264 unmodified lines
modified:tests/test_content.py+1 added-1 removed
61 unmodified lines
6263@pytest.mark.asyncio64async def test_async_bytesio_content():65 class AsyncBytesIO:66 def __init__(self, content):66 def __init__(self, content: bytes):67 self._idx = 068 self._content = content6970 async def aread(self, chunk_size: int) -> bytes:
380 unmodified lines
modified:setup.cfg+1 added
14 unmodified lines
15disallow_untyped_decorators = True16warn_redundant_casts = True17strict_concatenate = True18disallow_incomplete_defs = True19warn_return_any = True2021[mypy-tests.*]22disallow_untyped_defs = False23check_untyped_defs = True
17 unmodified lines