From 2750f0f82afadf1b0da64d0c6f3075d0ac568bc0 Mon Sep 17 00:00:00 2001 From: Stephen Sadowski Date: Tue, 1 Feb 2022 15:15:55 -0600 Subject: [PATCH] lint: fixed linting (again) across all files --- examples/request_stream/client.py | 2 +- sanic/config.py | 2 +- sanic/headers.py | 2 +- sanic/utils.py | 2 +- setup.py | 11 +++++++---- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/request_stream/client.py b/examples/request_stream/client.py index a59c4c23..c6c4f73d 100644 --- a/examples/request_stream/client.py +++ b/examples/request_stream/client.py @@ -6,5 +6,5 @@ data = "" for i in range(1, 250000): data += str(i) -r = requests.post('http://0.0.0.0:8000/stream', data=data) +r = requests.post("http://0.0.0.0:8000/stream", data=data) print(r.text) diff --git a/sanic/config.py b/sanic/config.py index ac147ef3..2e387ebd 100644 --- a/sanic/config.py +++ b/sanic/config.py @@ -39,7 +39,7 @@ DEFAULT_CONFIG = { "REQUEST_TIMEOUT": 60, # 60 seconds "RESPONSE_TIMEOUT": 60, # 60 seconds "USE_UVLOOP": _default, - "WEBSOCKET_MAX_SIZE": 2 ** 20, # 1 megabyte + "WEBSOCKET_MAX_SIZE": 2**20, # 1 megabyte "WEBSOCKET_PING_INTERVAL": 20, "WEBSOCKET_PING_TIMEOUT": 20, } diff --git a/sanic/headers.py b/sanic/headers.py index b4457653..5e4ded03 100644 --- a/sanic/headers.py +++ b/sanic/headers.py @@ -18,7 +18,7 @@ Options = Dict[str, Union[int, str]] # key=value fields in various headers OptionsIterable = Iterable[Tuple[str, str]] # May contain duplicate keys _token, _quoted = r"([\w!#$%&'*+\-.^_`|~]+)", r'"([^"]*)"' -_param = re.compile(fr";\s*{_token}=(?:{_token}|{_quoted})", re.ASCII) +_param = re.compile(rf";\s*{_token}=(?:{_token}|{_quoted})", re.ASCII) _firefox_quote_escape = re.compile(r'\\"(?!; |\s*$)') _ipv6 = "(?:[0-9A-Fa-f]{0,4}:){2,7}[0-9A-Fa-f]{0,4}" _ipv6_re = re.compile(_ipv6) diff --git a/sanic/utils.py b/sanic/utils.py index f972eed1..ef214a6b 100644 --- a/sanic/utils.py +++ b/sanic/utils.py @@ -22,7 +22,7 @@ def str_to_bool(val: str) -> bool: elif val.lower() in ["n", "no", "f", "false", "off", "0"]: return False else: - raise ValueError(f'String value {val} cannot be converted to bool') + raise ValueError(f"String value {val} cannot be converted to bool") def load_module_from_file_location( diff --git a/setup.py b/setup.py index dfd8d605..41cd8beb 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,9 @@ def open_local(paths, mode="r", encoding="utf8"): with open_local(["sanic", "__version__.py"], encoding="latin1") as fp: try: - version = re.findall(r"^__version__ = \"([^']+)\"\r?$", fp.read(), re.M)[0] + version = re.findall( + r"^__version__ = \"([^']+)\"\r?$", fp.read(), re.M + )[0] except IndexError: raise RuntimeError("Unable to determine version.") @@ -73,7 +75,9 @@ setup_kwargs = { "entry_points": {"console_scripts": ["sanic = sanic.__main__:main"]}, } -env_dependency = '; sys_platform != "win32" ' 'and implementation_name == "cpython"' +env_dependency = ( + '; sys_platform != "win32" ' 'and implementation_name == "cpython"' +) ujson = "ujson>=1.35" + env_dependency uvloop = "uvloop>=0.5.3" + env_dependency types_ujson = "types-ujson" + env_dependency @@ -140,8 +144,7 @@ def strtobool(val: str) -> bool: elif val.lower() in ["n", "no", "f", "false", "off", "0"]: return False else: - raise ValueError(f'String value {val} cannot be converted to bool') - + raise ValueError(f"String value {val} cannot be converted to bool") if strtobool(os.environ.get("SANIC_NO_UJSON", "no")):