Removed flake8, black and isort; moving towards ruff default settings instead.
This commit is contained in:
parent
469cb1663b
commit
e4daf1ab21
|
@ -9,7 +9,6 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
|
||||
# Add support for auto-doc
|
||||
|
||||
|
||||
|
@ -20,7 +19,6 @@ sys.path.insert(0, root_directory)
|
|||
|
||||
import sanic # noqa: E402
|
||||
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
extensions = [
|
||||
|
|
|
@ -2,7 +2,6 @@ import asyncio
|
|||
|
||||
from sanic import Sanic
|
||||
|
||||
|
||||
app = Sanic("Example")
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ from random import randint
|
|||
from sanic import Sanic
|
||||
from sanic.response import text
|
||||
|
||||
|
||||
app = Sanic("Example")
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ from functools import wraps
|
|||
from sanic import Sanic
|
||||
from sanic.response import json
|
||||
|
||||
|
||||
app = Sanic("Example")
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from sanic import Blueprint, Sanic
|
||||
from sanic.response import text
|
||||
|
||||
|
||||
"""
|
||||
Demonstrates that blueprint request middleware are executed in the order they
|
||||
are added. And blueprint response middleware are executed in _reverse_ order.
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from sanic import Blueprint, Sanic
|
||||
from sanic.response import file, json
|
||||
|
||||
|
||||
app = Sanic("Example")
|
||||
blueprint = Blueprint("bp_example", url_prefix="/my_blueprint")
|
||||
blueprint2 = Blueprint("bp_example2", url_prefix="/my_blueprint2")
|
||||
|
|
|
@ -2,7 +2,6 @@ from asyncio import sleep
|
|||
|
||||
from sanic import Sanic, response
|
||||
|
||||
|
||||
app = Sanic("DelayedResponseApp", strict_slashes=True)
|
||||
app.config.AUTO_EXTEND = False
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ an external service.
|
|||
from sanic.exceptions import SanicException
|
||||
from sanic.handlers import ErrorHandler
|
||||
|
||||
|
||||
"""
|
||||
Imports and code relevant for our CustomHandler class
|
||||
(Ordinarily this would be in a separate file)
|
||||
|
@ -39,7 +38,6 @@ server's error_handler to an instance of our CustomHandler
|
|||
|
||||
from sanic import Sanic
|
||||
|
||||
|
||||
handler = CustomHandler()
|
||||
app = Sanic("Example", error_handler=handler)
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from sanic import Sanic, response
|
||||
|
||||
|
||||
app = Sanic("Example")
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ from sanic import Sanic, response, text
|
|||
from sanic.handlers import ErrorHandler
|
||||
from sanic.server.async_server import AsyncioServer
|
||||
|
||||
|
||||
HTTP_PORT = 9999
|
||||
HTTPS_PORT = 8888
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import httpx
|
|||
from sanic import Sanic
|
||||
from sanic.response import json
|
||||
|
||||
|
||||
app = Sanic("Example")
|
||||
|
||||
sem = None
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import logging
|
||||
|
||||
from contextvars import ContextVar
|
||||
|
||||
from sanic import Sanic, response
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import logging
|
||||
import socket
|
||||
|
||||
from os import getenv
|
||||
from platform import node
|
||||
from uuid import getnode as get_mac
|
||||
|
@ -11,7 +10,6 @@ from sanic import Sanic
|
|||
from sanic.request import Request
|
||||
from sanic.response import json
|
||||
|
||||
|
||||
log = logging.getLogger("logdna")
|
||||
log.setLevel(logging.INFO)
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ Modify header or status in response
|
|||
|
||||
from sanic import Sanic, response
|
||||
|
||||
|
||||
app = Sanic("Example")
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ import logging
|
|||
|
||||
from sanic import Sanic, text
|
||||
|
||||
|
||||
logging_format = "[%(asctime)s] %(process)d-%(levelname)s "
|
||||
logging_format += "%(module)s::%(funcName)s():l%(lineno)d: "
|
||||
logging_format += "%(message)s"
|
||||
|
|
|
@ -11,7 +11,6 @@ Run with xdist params:
|
|||
import re
|
||||
|
||||
import pytest
|
||||
|
||||
from sanic_testing import SanicTestClient
|
||||
from sanic_testing.testing import PORT as PORT_BASE
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from sanic import Sanic, response
|
||||
|
||||
|
||||
app = Sanic("Example")
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import requests
|
||||
|
||||
|
||||
# Warning: This is a heavy process.
|
||||
|
||||
data = ""
|
||||
|
|
|
@ -4,7 +4,6 @@ from sanic.response import stream, text
|
|||
from sanic.views import HTTPMethodView
|
||||
from sanic.views import stream as stream_decorator
|
||||
|
||||
|
||||
bp = Blueprint("bp_example")
|
||||
app = Sanic("Example")
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ from sanic import Sanic, response
|
|||
from sanic.config import Config
|
||||
from sanic.exceptions import RequestTimeout
|
||||
|
||||
|
||||
Config.REQUEST_TIMEOUT = 1
|
||||
app = Sanic("Example")
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ from sanic import Sanic
|
|||
from sanic.exceptions import SanicException
|
||||
from sanic.handlers import ErrorHandler
|
||||
|
||||
|
||||
rollbar.init(getenv("ROLLBAR_API_KEY"))
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ from pathlib import Path
|
|||
|
||||
from sanic import Sanic, response
|
||||
|
||||
|
||||
app = Sanic("Example")
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import uvloop
|
|||
|
||||
from sanic import Sanic, response
|
||||
|
||||
|
||||
app = Sanic("Example")
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import asyncio
|
||||
|
||||
from signal import SIGINT, signal
|
||||
|
||||
import uvloop
|
||||
|
@ -7,7 +6,6 @@ import uvloop
|
|||
from sanic import Sanic, response
|
||||
from sanic.server import AsyncioServer
|
||||
|
||||
|
||||
app = Sanic("Example")
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ from sentry_sdk.integrations.sanic import SanicIntegration
|
|||
from sanic import Sanic
|
||||
from sanic.response import json
|
||||
|
||||
|
||||
sentry_init(
|
||||
dsn=getenv("SENTRY_DSN"),
|
||||
integrations=[SanicIntegration()],
|
||||
|
|
|
@ -2,7 +2,6 @@ from sanic import Sanic
|
|||
from sanic.response import text
|
||||
from sanic.views import HTTPMethodView
|
||||
|
||||
|
||||
app = Sanic("some_name")
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from sanic import Sanic
|
||||
|
||||
|
||||
app = Sanic("Example")
|
||||
|
||||
app.static("/", "./static")
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from sanic import Sanic
|
||||
from sanic import response as res
|
||||
|
||||
|
||||
app = Sanic("Example")
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ from sanic import Sanic, response
|
|||
from sanic.exceptions import ServerError
|
||||
from sanic.log import logger as log
|
||||
|
||||
|
||||
app = Sanic("Example")
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from sanic import Sanic, response
|
||||
|
||||
|
||||
app = Sanic("Example")
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from sanic import Sanic, response
|
||||
|
||||
|
||||
app = Sanic("Example")
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ from sanic import Sanic
|
|||
from sanic.blueprints import Blueprint
|
||||
from sanic.response import json
|
||||
|
||||
|
||||
app = Sanic(name="blue-print-group-version-example")
|
||||
|
||||
bp1 = Blueprint(name="ultron", url_prefix="/ultron")
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from sanic import Sanic, response
|
||||
from sanic.blueprints import Blueprint
|
||||
|
||||
|
||||
# Usage
|
||||
# curl -H "Host: example.com" localhost:8000
|
||||
# curl -H "Host: sub.example.com" localhost:8000
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from sanic import Sanic
|
||||
from sanic.response import redirect
|
||||
|
||||
|
||||
app = Sanic("Example")
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import re
|
||||
|
||||
from pathlib import Path
|
||||
from textwrap import indent
|
||||
|
||||
from emoji import EMOJI
|
||||
|
||||
|
||||
COLUMN_PATTERN = re.compile(r"---:1\s*(.*?)\s*:--:1\s*(.*?)\s*:---", re.DOTALL)
|
||||
PYTHON_HIGHLIGHT_PATTERN = re.compile(r"```python\{+.*?\}", re.DOTALL)
|
||||
BASH_HIGHLIGHT_PATTERN = re.compile(r"```bash\{+.*?\}", re.DOTALL)
|
||||
|
|
|
@ -2,5 +2,4 @@ from pathlib import Path
|
|||
|
||||
from webapp.worker.factory import create_app
|
||||
|
||||
|
||||
app = create_app(Path(__file__).parent)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import re
|
||||
|
||||
from textwrap import dedent
|
||||
|
||||
from html5tagger import HTML, Builder, E # type: ignore
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from .page import Page
|
||||
from .renderer import PageRenderer
|
||||
|
||||
|
||||
__all__ = ["Page", "PageRenderer"]
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import annotations
|
|||
import importlib
|
||||
import inspect
|
||||
import pkgutil
|
||||
|
||||
from collections import defaultdict
|
||||
from dataclasses import dataclass, field
|
||||
from html import escape
|
||||
|
|
|
@ -11,7 +11,6 @@ from ..layouts.main import MainLayout
|
|||
from ..markdown import render_markdown
|
||||
from .docobject import organize_docobjects
|
||||
|
||||
|
||||
_PAGE_CACHE: dict[
|
||||
str, dict[str, tuple[Page | None, Page | None, Page | None]]
|
||||
] = {}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import re
|
||||
|
||||
|
||||
SLUGIFY_PATTERN = re.compile(r"[^a-zA-Z0-9-]")
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ from webapp.display.page import Page
|
|||
from webapp.display.search.renderer import SearchRenderer
|
||||
from webapp.display.search.search import Document, Searcher, Stemmer
|
||||
|
||||
|
||||
bp = Blueprint("search", url_prefix="/<language>/search")
|
||||
|
||||
|
||||
|
|
|
@ -2,5 +2,4 @@ from sanic import Blueprint
|
|||
|
||||
from .search import bp as search_bp
|
||||
|
||||
|
||||
bp = Blueprint.group(search_bp)
|
||||
|
|
|
@ -5,7 +5,6 @@ from queue import Empty, Queue
|
|||
from typing import Any
|
||||
|
||||
import ujson
|
||||
|
||||
from sanic import Request, Sanic, Websocket
|
||||
|
||||
|
||||
|
|
|
@ -18,30 +18,12 @@ ignore = [
|
|||
"ISC001",
|
||||
"W191",
|
||||
]
|
||||
line-length = 79
|
||||
show-source = true
|
||||
show-fixes = true
|
||||
|
||||
[tool.ruff.isort]
|
||||
known-first-party = ["sanic"]
|
||||
known-third-party = ["pytest"]
|
||||
lines-after-imports = 2
|
||||
lines-between-types = 1
|
||||
|
||||
[tool.black]
|
||||
line-length = 79
|
||||
|
||||
[tool.isort]
|
||||
atomic = true
|
||||
default_section = "THIRDPARTY"
|
||||
include_trailing_comma = true
|
||||
known_first_party = "sanic"
|
||||
known_third_party = "pytest"
|
||||
line_length = 79
|
||||
lines_after_imports = 2
|
||||
lines_between_types = 1
|
||||
multi_line_output = 3
|
||||
profile = "black"
|
||||
|
||||
[[tool.mypy.overrides]]
|
||||
module = [
|
||||
|
|
|
@ -36,7 +36,6 @@ from sanic.response import (
|
|||
)
|
||||
from sanic.server.websockets.impl import WebsocketImplProtocol as Websocket
|
||||
|
||||
|
||||
DefaultSanic: TypeAlias = "Sanic[Config, SimpleNamespace]"
|
||||
"""
|
||||
A type alias for a Sanic app with a default config and namespace.
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from sanic.cli.app import SanicCLI
|
||||
from sanic.compat import OS_IS_WINDOWS, enable_windows_color_support
|
||||
|
||||
|
||||
if OS_IS_WINDOWS:
|
||||
enable_windows_color_support()
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import logging
|
|||
import logging.config
|
||||
import re
|
||||
import sys
|
||||
|
||||
from asyncio import (
|
||||
AbstractEventLoop,
|
||||
CancelledError,
|
||||
|
@ -89,7 +88,6 @@ from sanic.worker.inspector import Inspector
|
|||
from sanic.worker.loader import CertLoader
|
||||
from sanic.worker.manager import WorkerManager
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
try:
|
||||
from sanic_ext import Extend # type: ignore
|
||||
|
@ -850,8 +848,8 @@ class Sanic(
|
|||
return
|
||||
if blueprint.name in self.blueprints:
|
||||
assert self.blueprints[blueprint.name] is blueprint, (
|
||||
'A blueprint with the name "{}" is already registered. '
|
||||
"Blueprint names must be unique.".format(blueprint.name)
|
||||
f'A blueprint with the name "{blueprint.name}" is already registered. '
|
||||
"Blueprint names must be unique."
|
||||
)
|
||||
else:
|
||||
self.blueprints[blueprint.name] = blueprint
|
||||
|
|
|
@ -4,7 +4,6 @@ from contextlib import suppress
|
|||
from importlib import import_module
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sanic import Sanic
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import re
|
||||
import sys
|
||||
|
||||
from os import environ
|
||||
|
||||
from sanic.helpers import is_atty
|
||||
|
||||
|
||||
BASE_LOGO = """
|
||||
|
||||
Sanic
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
from contextlib import contextmanager
|
||||
from queue import Queue
|
||||
from threading import Thread
|
||||
|
||||
|
||||
if os.name == "nt": # noqa
|
||||
import ctypes # noqa
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from socket import socket
|
||||
|
@ -12,7 +11,6 @@ from sanic.application.constants import Mode, Server, ServerStage
|
|||
from sanic.log import VerbosityFilter, logger
|
||||
from sanic.server.async_server import AsyncioServer
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sanic import Sanic
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import warnings
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from sanic.compat import Header
|
||||
|
@ -15,7 +14,6 @@ from sanic.response import BaseHTTPResponse
|
|||
from sanic.server import ConnInfo
|
||||
from sanic.server.websockets.connection import WebSocketConnection
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sanic import Sanic
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import re
|
||||
|
||||
from typing import Any, Optional
|
||||
|
||||
from sanic.base.meta import SanicMeta
|
||||
|
@ -11,7 +10,6 @@ from sanic.mixins.routes import RouteMixin
|
|||
from sanic.mixins.signals import SignalMixin
|
||||
from sanic.mixins.static import StaticMixin
|
||||
|
||||
|
||||
VALID_NAME = re.compile(r"^[a-zA-Z_][a-zA-Z0-9_\-]*$")
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
from .blueprints import BlueprintGroup
|
||||
|
||||
|
||||
__all__ = ["BlueprintGroup"] # noqa: F405
|
||||
|
|
|
@ -2,7 +2,6 @@ from __future__ import annotations
|
|||
|
||||
import asyncio
|
||||
import sys
|
||||
|
||||
from collections import defaultdict
|
||||
from collections.abc import MutableSequence
|
||||
from copy import deepcopy
|
||||
|
@ -33,7 +32,6 @@ from sanic.models.handler_types import (
|
|||
RouteHandler,
|
||||
)
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sanic import Sanic
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import os
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
from argparse import Namespace
|
||||
from functools import partial
|
||||
from textwrap import indent
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
|
||||
from http.client import RemoteDisconnected
|
||||
from textwrap import indent
|
||||
from typing import Any
|
||||
|
@ -13,7 +12,6 @@ from sanic.application.logo import get_logo
|
|||
from sanic.application.motd import MOTDTTY
|
||||
from sanic.log import Colors
|
||||
|
||||
|
||||
try: # no cov
|
||||
from ujson import dumps, loads
|
||||
except ModuleNotFoundError: # no cov
|
||||
|
|
|
@ -3,7 +3,6 @@ import os
|
|||
import platform
|
||||
import signal
|
||||
import sys
|
||||
|
||||
from contextlib import contextmanager
|
||||
from enum import Enum
|
||||
from typing import Awaitable, Literal, Union
|
||||
|
@ -13,7 +12,6 @@ from multidict import CIMultiDict # type: ignore
|
|||
from sanic.helpers import Default
|
||||
from sanic.log import error_logger
|
||||
|
||||
|
||||
StartMethod = Union[
|
||||
Default, Literal["fork"], Literal["forkserver"], Literal["spawn"]
|
||||
]
|
||||
|
|
|
@ -14,7 +14,6 @@ from sanic.http import Http
|
|||
from sanic.log import error_logger
|
||||
from sanic.utils import load_module_from_file_location, str_to_bool
|
||||
|
||||
|
||||
FilterWarningType = Union[
|
||||
Literal["default"],
|
||||
Literal["error"],
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
from .response import Cookie, CookieJar
|
||||
|
||||
|
||||
__all__ = ("Cookie", "CookieJar")
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import re
|
||||
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from sanic.cookies.response import Cookie
|
||||
from sanic.log import deprecation
|
||||
from sanic.request.parameters import RequestParameters
|
||||
|
||||
|
||||
COOKIE_NAME_RESERVED_CHARS = re.compile(
|
||||
'[\x00-\x1F\x7F-\xFF()<>@,;:\\\\"/[\\]?={} \x09]'
|
||||
)
|
||||
|
|
|
@ -2,20 +2,17 @@ from __future__ import annotations
|
|||
|
||||
import re
|
||||
import string
|
||||
|
||||
from datetime import datetime
|
||||
from typing import TYPE_CHECKING, Any, Union
|
||||
|
||||
from sanic.exceptions import ServerError
|
||||
from sanic.log import deprecation
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sanic.compat import Header
|
||||
|
||||
from typing import Literal
|
||||
|
||||
|
||||
SameSite = Union[
|
||||
Literal["Strict"],
|
||||
Literal["Lax"],
|
||||
|
|
|
@ -16,7 +16,6 @@ from __future__ import annotations
|
|||
|
||||
import sys
|
||||
import typing as t
|
||||
|
||||
from functools import partial
|
||||
from traceback import extract_tb
|
||||
|
||||
|
@ -26,7 +25,6 @@ from sanic.log import deprecation, logger
|
|||
from sanic.pages.error import ErrorPage
|
||||
from sanic.response import html, json, text
|
||||
|
||||
|
||||
dumps: t.Callable[..., str]
|
||||
try:
|
||||
from ujson import dumps
|
||||
|
|
|
@ -2,7 +2,6 @@ from .content_range import ContentRangeHandler
|
|||
from .directory import DirectoryHandler
|
||||
from .error import ErrorHandler
|
||||
|
||||
|
||||
__all__ = (
|
||||
"ContentRangeHandler",
|
||||
"DirectoryHandler",
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from sanic.exceptions import (
|
||||
|
@ -11,7 +10,6 @@ from sanic.exceptions import (
|
|||
)
|
||||
from sanic.models.protocol_types import Range
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sanic import Request
|
||||
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
|
||||
from typing import Any, Dict, Iterable, Tuple, Union
|
||||
from urllib.parse import unquote
|
||||
|
||||
from sanic.exceptions import InvalidHeader
|
||||
from sanic.helpers import STATUS_CODES
|
||||
|
||||
|
||||
# TODO:
|
||||
# - the Options object should be a typed object to allow for less casting
|
||||
# across the application (in request.py for example)
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
"""Defines basics of HTTP standard."""
|
||||
|
||||
import sys
|
||||
|
||||
from importlib import import_module
|
||||
from inspect import ismodule
|
||||
from typing import Dict
|
||||
|
||||
|
||||
STATUS_CODES: Dict[int, bytes] = {
|
||||
100: b"Continue",
|
||||
101: b"Switching Protocols",
|
||||
|
|
|
@ -2,5 +2,4 @@ from .constants import Stage
|
|||
from .http1 import Http
|
||||
from .http3 import Http3
|
||||
|
||||
|
||||
__all__ = ("Http", "Stage", "Http3")
|
||||
|
|
|
@ -2,7 +2,6 @@ from __future__ import annotations
|
|||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sanic.request import Request
|
||||
from sanic.response import BaseHTTPResponse
|
||||
|
@ -25,7 +24,6 @@ from sanic.http.stream import Stream
|
|||
from sanic.log import access_logger, error_logger, logger
|
||||
from sanic.touchup import TouchUpMeta
|
||||
|
||||
|
||||
HTTP_CONTINUE = b"HTTP/1.1 100 Continue\r\n\r\n"
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from ssl import SSLContext
|
||||
from typing import (
|
||||
|
@ -28,7 +27,6 @@ from sanic.log import Colors, logger
|
|||
from sanic.models.protocol_types import TransportProtocol
|
||||
from sanic.models.server_types import ConnInfo
|
||||
|
||||
|
||||
try:
|
||||
from aioquic.h0.connection import H0_ALPN, H0Connection
|
||||
from aioquic.h3.connection import H3_ALPN, H3Connection
|
||||
|
|
|
@ -4,7 +4,6 @@ from typing import TYPE_CHECKING
|
|||
|
||||
from sanic.http.constants import Stage
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sanic.response import BaseHTTPResponse
|
||||
from sanic.server.protocols.http_protocol import HttpProtocol
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from .context import process_to_context
|
||||
from .creators import get_ssl_context
|
||||
|
||||
|
||||
__all__ = ("get_ssl_context", "process_to_context")
|
||||
|
|
|
@ -2,12 +2,10 @@ from __future__ import annotations
|
|||
|
||||
import os
|
||||
import ssl
|
||||
|
||||
from typing import Any, Iterable
|
||||
|
||||
from sanic.log import logger
|
||||
|
||||
|
||||
# Only allow secure ciphers, notably leaving out AES-CBC mode
|
||||
# OpenSSL chooses ECDSA or RSA depending on the cert in use
|
||||
CIPHERS_TLS12 = [
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import annotations
|
|||
import ssl
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from contextlib import suppress
|
||||
from pathlib import Path
|
||||
|
@ -22,7 +21,6 @@ from sanic.exceptions import SanicException
|
|||
from sanic.helpers import Default
|
||||
from sanic.http.tls.context import CertSimple, SanicSSLContext
|
||||
|
||||
|
||||
try:
|
||||
import trustme
|
||||
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
import logging
|
||||
import sys
|
||||
|
||||
from enum import Enum
|
||||
from typing import TYPE_CHECKING, Any, Dict
|
||||
from warnings import warn
|
||||
|
||||
from sanic.helpers import is_atty
|
||||
|
||||
|
||||
# Python 3.11 changed the way Enum formatting works for mixed-in types.
|
||||
if sys.version_info < (3, 11, 0):
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ from sanic.models.futures import FutureRoute, FutureStatic
|
|||
from sanic.models.handler_types import RouteHandler
|
||||
from sanic.types import HashableDict
|
||||
|
||||
|
||||
RouteWrapper = Callable[
|
||||
[RouteHandler], Union[RouteHandler, Tuple[Route, RouteHandler]]
|
||||
]
|
||||
|
|
|
@ -2,7 +2,6 @@ from __future__ import annotations
|
|||
|
||||
import os
|
||||
import platform
|
||||
|
||||
from asyncio import (
|
||||
AbstractEventLoop,
|
||||
CancelledError,
|
||||
|
@ -64,7 +63,6 @@ from sanic.worker.multiplexer import WorkerMultiplexer
|
|||
from sanic.worker.reloader import Reloader
|
||||
from sanic.worker.serve import worker_serve
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sanic import Sanic
|
||||
from sanic.application.state import ApplicationState
|
||||
|
@ -74,7 +72,6 @@ SANIC_PACKAGES = ("sanic-routing", "sanic-testing", "sanic-ext")
|
|||
|
||||
from typing import Literal
|
||||
|
||||
|
||||
HTTPVersion = Union[HTTP, Literal[1], Literal[3]]
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import asyncio
|
||||
|
||||
from typing import Any, Awaitable, Callable, MutableMapping, Optional, Union
|
||||
|
||||
from sanic.exceptions import BadRequest
|
||||
from sanic.models.protocol_types import TransportProtocol
|
||||
from sanic.server.websockets.connection import WebSocketConnection
|
||||
|
||||
|
||||
ASGIScope = MutableMapping[str, Any]
|
||||
ASGIMessage = MutableMapping[str, Any]
|
||||
ASGISend = Callable[[ASGIMessage], Awaitable[None]]
|
||||
|
|
|
@ -2,11 +2,9 @@ from asyncio.events import AbstractEventLoop
|
|||
from typing import Any, Callable, Coroutine, Optional, TypeVar, Union
|
||||
|
||||
import sanic
|
||||
|
||||
from sanic import request
|
||||
from sanic.response import BaseHTTPResponse, HTTPResponse
|
||||
|
||||
|
||||
Sanic = TypeVar("Sanic", bound="sanic.Sanic")
|
||||
Request = TypeVar("Request", bound="request.Request")
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import annotations
|
|||
from asyncio import BaseTransport
|
||||
from typing import TYPE_CHECKING, AnyStr
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sanic.http.constants import HTTP
|
||||
from sanic.models.asgi import ASGIScope
|
||||
|
|
|
@ -2,7 +2,6 @@ from abc import ABCMeta
|
|||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
|
||||
CURRENT_DIR = Path(__file__).parent
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from typing import Any, Mapping
|
||||
|
||||
import tracerite.html
|
||||
|
||||
from html5tagger import E
|
||||
from tracerite import html_traceback, inspector
|
||||
|
||||
|
@ -9,7 +8,6 @@ from sanic.request import Request
|
|||
|
||||
from .base import BasePage
|
||||
|
||||
|
||||
# Avoid showing the request in the traceback variable inspectors
|
||||
inspector.blacklist_types += (Request,)
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ from .form import File, parse_multipart_form
|
|||
from .parameters import RequestParameters
|
||||
from .types import Request
|
||||
|
||||
|
||||
__all__ = (
|
||||
"File",
|
||||
"parse_multipart_form",
|
||||
|
|
|
@ -2,7 +2,6 @@ from __future__ import annotations
|
|||
|
||||
import email.utils
|
||||
import unicodedata
|
||||
|
||||
from typing import NamedTuple
|
||||
from urllib.parse import unquote
|
||||
|
||||
|
|
|
@ -19,14 +19,12 @@ from sanic.http.stream import Stream
|
|||
from sanic.models.asgi import ASGIScope
|
||||
from sanic.models.http_types import Credentials
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sanic.app import Sanic
|
||||
from sanic.config import Config
|
||||
from sanic.server import ConnInfo
|
||||
|
||||
import uuid
|
||||
|
||||
from collections import defaultdict
|
||||
from urllib.parse import parse_qs, parse_qsl, urlunparse
|
||||
|
||||
|
@ -60,7 +58,6 @@ from sanic.response import BaseHTTPResponse, HTTPResponse
|
|||
from .form import parse_multipart_form
|
||||
from .parameters import RequestParameters
|
||||
|
||||
|
||||
try:
|
||||
from ujson import loads as json_loads # type: ignore
|
||||
except ImportError:
|
||||
|
|
|
@ -17,7 +17,6 @@ from .types import (
|
|||
json_dumps,
|
||||
)
|
||||
|
||||
|
||||
__all__ = (
|
||||
"BaseHTTPResponse",
|
||||
"HTTPResponse",
|
||||
|
|
|
@ -24,7 +24,6 @@ from sanic.helpers import (
|
|||
)
|
||||
from sanic.http import Http
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sanic.asgi import ASGIApp
|
||||
from sanic.http.http3 import HTTPReceiver
|
||||
|
|
|
@ -15,7 +15,6 @@ from sanic.errorpages import check_error_format
|
|||
from sanic.exceptions import MethodNotAllowed, NotFound, SanicException
|
||||
from sanic.models.handler_types import RouteHandler
|
||||
|
||||
|
||||
ROUTER_CACHE_SIZE = 1024
|
||||
ALLOWED_LABELS = ("__file_uri__",)
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ from sanic.server.loop import try_use_uvloop
|
|||
from sanic.server.protocols.http_protocol import HttpProtocol
|
||||
from sanic.server.runners import serve
|
||||
|
||||
|
||||
__all__ = (
|
||||
"AsyncioServer",
|
||||
"ConnInfo",
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from sanic.exceptions import SanicException
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sanic import Sanic
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import annotations
|
|||
from inspect import isawaitable
|
||||
from typing import TYPE_CHECKING, Any, Callable, Iterable
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sanic import Sanic
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import asyncio
|
||||
import sys
|
||||
|
||||
from os import getenv
|
||||
|
||||
from sanic.compat import OS_IS_WINDOWS
|
||||
|
|
|
@ -4,12 +4,10 @@ from typing import TYPE_CHECKING
|
|||
|
||||
from sanic.exceptions import RequestCancelled
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sanic.app import Sanic
|
||||
|
||||
import asyncio
|
||||
|
||||
from asyncio.transports import Transport
|
||||
from time import monotonic as current_time
|
||||
|
||||
|
|
|
@ -6,12 +6,10 @@ from sanic.http.constants import HTTP
|
|||
from sanic.http.http3 import Http3
|
||||
from sanic.touchup.meta import TouchUpMeta
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sanic.app import Sanic
|
||||
|
||||
import sys
|
||||
|
||||
from asyncio import CancelledError
|
||||
from time import monotonic as current_time
|
||||
|
||||
|
@ -26,7 +24,6 @@ from sanic.models.server_types import ConnInfo
|
|||
from sanic.request import Request
|
||||
from sanic.server.protocols.base_protocol import SanicProtocol
|
||||
|
||||
|
||||
ConnectionProtocol = type("ConnectionProtocol", (), {})
|
||||
try:
|
||||
from aioquic.asyncio import QuicConnectionProtocol
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from typing import TYPE_CHECKING, Optional, Sequence, cast
|
||||
|
||||
|
||||
try: # websockets < 11.0
|
||||
from websockets.connection import State
|
||||
from websockets.server import ServerConnection as ServerProtocol
|
||||
|
@ -16,7 +15,6 @@ from sanic.server import HttpProtocol
|
|||
|
||||
from ..websockets.impl import WebsocketImplProtocol
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from websockets import http11
|
||||
|
||||
|
|
|
@ -8,14 +8,12 @@ from sanic.exceptions import ServerError
|
|||
from sanic.http.constants import HTTP
|
||||
from sanic.http.tls import get_ssl_context
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sanic.app import Sanic
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
import socket
|
||||
|
||||
from functools import partial
|
||||
from signal import SIG_IGN, SIGINT, SIGTERM
|
||||
from signal import signal as signal_func
|
||||
|
@ -29,7 +27,6 @@ from sanic.server.async_server import AsyncioServer
|
|||
from sanic.server.protocols.http_protocol import Http3Protocol, HttpProtocol
|
||||
from sanic.server.socket import bind_unix_socket, remove_unix_socket
|
||||
|
||||
|
||||
try:
|
||||
from aioquic.asyncio import serve as quic_serve
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import os
|
|||
import secrets
|
||||
import socket
|
||||
import stat
|
||||
|
||||
from ipaddress import ip_address
|
||||
from typing import Any
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ from typing import (
|
|||
|
||||
from sanic.exceptions import InvalidUsage
|
||||
|
||||
|
||||
ASGIMessage = MutableMapping[str, Any]
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import asyncio
|
||||
import codecs
|
||||
|
||||
from typing import TYPE_CHECKING, AsyncIterator, List, Optional
|
||||
|
||||
from websockets.frames import Frame, Opcode
|
||||
|
@ -8,7 +7,6 @@ from websockets.typing import Data
|
|||
|
||||
from sanic.exceptions import ServerError
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .impl import WebsocketImplProtocol
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user