Skip to content
Myr

Remove and dissallow unused type ignores (#2470)

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

* Remove and dissallow unused type ignores * add pragmas * fix ignore

authored by Adrian Garcia Badaracco · committed by GitHub · parent 1fc6a52 · Browse files · 7 files+28 added−24 removed
This commit

State

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

Diff stats

7 files+28 added−24 removed

  • tests:+14 added−13 removed
  • other:+14 added−11 removed

7 files+28 added−24 removed

modified:httpx/_transports/mock.py+1 added-1 removed
27 unmodified lines
28 # return the result.2930 # https://simonwillison.net/2020/Sep/2/await-me-maybe/31 if asyncio.iscoroutine(response):32 response = await response # type: ignore[func-returns-value,assignment]32 response = await response3334 return response
modified:httpx/_config.py+9 added-7 removed
1import os2import ssl3import sys4import typing5from pathlib import Path67import certifi
117 unmodified lines
125 context.check_hostname = True126127 # Signal to server support for PHA in TLS 1.3. Raises an128 # AttributeError if only read-only access is implemented.129 if sys.version_info >= (3, 8): # pragma: no cover128 try:129 context.post_handshake_auth = True # type: ignore130 except AttributeError: # pragma: no cover131 pass130 try:131 context.post_handshake_auth = True132 except AttributeError: # pragma: no cover133 pass134135 # Disable using 'commonName' for SSLContext.check_hostname136 # when the 'subjectAltName' extension isn't available.137 try:136 context.hostname_checks_common_name = False # type: ignore138 context.hostname_checks_common_name = False139 except AttributeError: # pragma: no cover140 pass141142 if ca_bundle_path.is_file():
20 unmodified lines
163 if ssl.HAS_ALPN:164 alpn_idents = ["http/1.1", "h2"] if self.http2 else ["http/1.1"]165 context.set_alpn_protocols(alpn_idents)166165 if hasattr(context, "keylog_filename"): # pragma: no cover (Available in 3.8+)167 if sys.version_info >= (3, 8): # pragma: no cover168 keylogfile = os.environ.get("SSLKEYLOGFILE")169 if keylogfile and self.trust_env:168 context.keylog_filename = keylogfile # type: ignore170 context.keylog_filename = keylogfile171172 return context173174 def _load_client_certs(self, ssl_context: ssl.SSLContext) -> None:
191 unmodified lines
modified:httpx/_content.py+1 added-1 removed
187 unmodified lines
188 """189 Handles encoding the given `content`, `data`, `files`, and `json`,190 returning a two-tuple of (<headers>, <stream>).191 """192 if data is not None and not isinstance(data, Mapping): # type: ignore192 if data is not None and not isinstance(data, Mapping):193 # We prefer to separate `content=<bytes|str|byte iterator|bytes aiterator>`194 # for raw request content, and `data=<form data>` for url encoded or195 # multipart form content.196 #
39 unmodified lines
modified:httpx/_status_codes.py+2 added-2 removed
20 unmodified lines
21 * RFC 8470: Using Early Data in HTTP22 """2324 def __new__(cls, value: int, phrase: str = "") -> "codes":25 obj = int.__new__(cls, value) # type: ignore25 obj = int.__new__(cls, value)26 obj._value_ = value2728 obj.phrase = phrase # type: ignore28 obj.phrase = phrase # type: ignore[attr-defined]29 return obj3031 def __str__(self) -> str:32 return str(self.value)
126 unmodified lines
modified:tests/test_config.py+12 added-11 removed
176 unmodified lines
177 reason="requires OpenSSL 1.1.1 or higher",178)179@pytest.mark.skipif(sys.version_info < (3, 8), reason="requires python3.8 or higher")180def test_ssl_config_support_for_keylog_file(tmpdir, monkeypatch): # pragma: no cover181 if sys.version_info > (3, 8):181 with monkeypatch.context() as m:182 m.delenv("SSLKEYLOGFILE", raising=False)182 with monkeypatch.context() as m:183 m.delenv("SSLKEYLOGFILE", raising=False)184184 context = httpx.create_ssl_context(trust_env=True)185 context = httpx.create_ssl_context(trust_env=True)186186 assert context.keylog_filename is None # type: ignore187 assert context.keylog_filename is None188188 filename = str(tmpdir.join("test.log"))189 filename = str(tmpdir.join("test.log"))190190 with monkeypatch.context() as m:191 m.setenv("SSLKEYLOGFILE", filename)191 with monkeypatch.context() as m:192 m.setenv("SSLKEYLOGFILE", filename)193193 context = httpx.create_ssl_context(trust_env=True)194 context = httpx.create_ssl_context(trust_env=True)195195 assert context.keylog_filename == filename # type: ignore196 assert context.keylog_filename == filename197197 context = httpx.create_ssl_context(trust_env=False)198 context = httpx.create_ssl_context(trust_env=False)199199 assert context.keylog_filename is None # type: ignore200 assert context.keylog_filename is None201202203def test_proxy_from_url():204 proxy = httpx.Proxy("https://example.com")
19 unmodified lines
modified:tests/test_content.py+2 added-2 removed
103 unmodified lines
104 [part for part in stream]105106 # Support 'data' for compat with requests.107 with pytest.warns(DeprecationWarning):108 headers, stream = encode_request(data=hello_world()) # type: ignore108 headers, stream = encode_request(data=hello_world())109 assert isinstance(stream, typing.Iterable)110 assert not isinstance(stream, typing.AsyncIterable)111112 content = b"".join([part for part in stream])
21 unmodified lines
134 [part async for part in stream]135136 # Support 'data' for compat with requests.137 with pytest.warns(DeprecationWarning):138 headers, stream = encode_request(data=hello_world()) # type: ignore138 headers, stream = encode_request(data=hello_world())139 assert not isinstance(stream, typing.Iterable)140 assert isinstance(stream, typing.AsyncIterable)141142 content = b"".join([part async for part in stream])
308 unmodified lines
modified:setup.cfg+1 added
6 unmodified lines
7disallow_any_generics = True8ignore_missing_imports = True9no_implicit_optional = True10show_error_codes = True11warn_unused_ignores = True12warn_unused_configs = True13disallow_subclassing_any = True14check_untyped_defs = True15disallow_untyped_decorators = True
23 unmodified lines