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