|
19 | 19 |
|
20 | 20 | import ast
|
21 | 21 | import asyncio
|
22 |
| -import contextlib |
23 | 22 | import http.client
|
24 | 23 | import io
|
25 | 24 | import os
|
|
33 | 32 | import uuid
|
34 | 33 | from base64 import b64encode
|
35 | 34 | from collections.abc import Callable, Iterable, MutableMapping
|
| 35 | +from contextlib import suppress |
36 | 36 | from importlib import import_module
|
37 | 37 | from textwrap import dedent
|
38 | 38 | from types import EllipsisType
|
39 | 39 | from typing import Any, Required, TypeAlias, TypedDict, cast
|
40 | 40 | from urllib.parse import SplitResult, quote, quote_plus, urlsplit
|
41 | 41 |
|
42 |
| -with contextlib.suppress(ModuleNotFoundError): |
| 42 | +with suppress(ModuleNotFoundError): |
43 | 43 | # pylint: disable=shadowed-import
|
44 | 44 | import dill as pickle # type: ignore[import-untyped, no-redef] # noqa: F811, B950 # nosec: B403
|
45 | 45 |
|
|
58 | 58 | except ModuleNotFoundError:
|
59 | 59 | socks = None # pylint: disable=invalid-name
|
60 | 60 |
|
61 |
| -if "DISABLE_UVLOOP" not in os.environ: |
62 |
| - with contextlib.suppress(ModuleNotFoundError): |
| 61 | +if os.environ.get("DISABLE_UVLOOP") not in {"y", "yes", "t", "true", "on", "1"}: |
| 62 | + with suppress(ModuleNotFoundError): |
63 | 63 | asyncio.set_event_loop_policy(import_module("uvloop").EventLoopPolicy())
|
64 | 64 |
|
65 |
| - |
66 |
| -FLUFL = True |
67 |
| - |
68 | 65 | E = eval( # pylint: disable=eval-used # nosec: B307
|
69 | 66 | "eval(repr((_:=[],_.append(_))[0]))[0][0]"
|
70 | 67 | )
|
71 | 68 |
|
72 | 69 | ErrorTuple: TypeAlias = tuple[int, str]
|
73 | 70 |
|
| 71 | +FLUFL = True |
| 72 | + |
74 | 73 |
|
75 | 74 | class Response(TypedDict): # noqa: D101
|
76 | 75 | # pylint: disable=missing-class-docstring
|
@@ -180,7 +179,7 @@ async def request( # noqa: C901
|
180 | 179 | if "Host" not in header_names:
|
181 | 180 | host: None | str = None
|
182 | 181 | if idna: # type: ignore[truthy-bool]
|
183 |
| - with contextlib.suppress(idna.core.InvalidCodepoint): |
| 182 | + with suppress(idna.core.InvalidCodepoint): |
184 | 183 | host = idna.encode(url.hostname).decode("ASCII")
|
185 | 184 | host = f"{host}:{url.port}" if url.port else host
|
186 | 185 | if not host:
|
@@ -684,7 +683,7 @@ def _run_and_print( # type: ignore[no-any-unimported]
|
684 | 683 | ReaderConsole.execute = _run_and_print
|
685 | 684 |
|
686 | 685 | # run the reader
|
687 |
| - with contextlib.suppress(EOFError): |
| 686 | + with suppress(EOFError): |
688 | 687 | _main(print_banner=False, clear_main=False)
|
689 | 688 |
|
690 | 689 | # restore the original method
|
|
0 commit comments