parent
f053551f89
commit
3faa10fbbe
3 changed files with 33 additions and 17 deletions
|
@ -13,7 +13,7 @@ dependencies = [
|
|||
"invoke",
|
||||
# lint
|
||||
"black",
|
||||
"ruff==0.0.278", # Ruff is moving really fast, so pinning for now.
|
||||
"ruff==0.0.278", # Ruff is moving really fast, so pinning for now.
|
||||
"toml",
|
||||
"flake8",
|
||||
"flake8-pyproject",
|
||||
|
@ -32,9 +32,11 @@ publish = "invoke publish {args}"
|
|||
docs = "invoke docs {args}"
|
||||
check = ["lint-py", "lint-js", "test-py", "test-js", "test-docs"]
|
||||
|
||||
lint = ["lint-py", "lint-js"]
|
||||
lint-py = "invoke lint-py {args}"
|
||||
lint-js = "invoke lint-js {args}"
|
||||
|
||||
test = ["test-py", "test-js", "test-docs"]
|
||||
test-py = "invoke test-py {args}"
|
||||
test-js = "invoke test-js"
|
||||
test-docs = "invoke test-docs"
|
||||
|
@ -56,7 +58,7 @@ warn_unused_ignores = true
|
|||
# --- Flake8 ---------------------------------------------------------------------------
|
||||
|
||||
[tool.flake8]
|
||||
select = ["RPY"] # only need to check with reactpy-flake8
|
||||
select = ["RPY"] # only need to check with reactpy-flake8
|
||||
exclude = ["**/node_modules/*", ".eggs/*", ".tox/*", "**/venv/*"]
|
||||
|
||||
# --- Ruff -----------------------------------------------------------------------------
|
||||
|
@ -95,7 +97,8 @@ select = [
|
|||
]
|
||||
ignore = [
|
||||
# TODO: turn this on later
|
||||
"N802", "N806", # allow TitleCase functions/variables
|
||||
"N802",
|
||||
"N806", # allow TitleCase functions/variables
|
||||
# We're not any cryptography
|
||||
"S311",
|
||||
# For loop variable re-assignment seems like an uncommon mistake
|
||||
|
@ -103,9 +106,12 @@ ignore = [
|
|||
# Let Black deal with line-length
|
||||
"E501",
|
||||
# Allow args/attrs to shadow built-ins
|
||||
"A002", "A003",
|
||||
"A002",
|
||||
"A003",
|
||||
# Allow unused args (useful for documenting what the parameter is for later)
|
||||
"ARG001", "ARG002", "ARG005",
|
||||
"ARG001",
|
||||
"ARG002",
|
||||
"ARG005",
|
||||
# Allow non-abstract empty methods in abstract base classes
|
||||
"B027",
|
||||
# Allow boolean positional values in function calls, like `dict.get(... True)`
|
||||
|
@ -113,9 +119,15 @@ ignore = [
|
|||
# If we're making an explicit comparison to a falsy value it was probably intentional
|
||||
"PLC1901",
|
||||
# Ignore checks for possible passwords
|
||||
"S105", "S106", "S107",
|
||||
"S105",
|
||||
"S106",
|
||||
"S107",
|
||||
# Ignore complexity
|
||||
"C901", "PLR0911", "PLR0912", "PLR0913", "PLR0915",
|
||||
"C901",
|
||||
"PLR0911",
|
||||
"PLR0912",
|
||||
"PLR0913",
|
||||
"PLR0915",
|
||||
]
|
||||
unfixable = [
|
||||
# Don't touch unused imports
|
||||
|
|
|
@ -48,7 +48,9 @@ class Options(CommonOptions):
|
|||
|
||||
# BackendType.configure
|
||||
def configure(
|
||||
app: Sanic, component: RootComponentConstructor, options: Options | None = None
|
||||
app: Sanic[Any, Any],
|
||||
component: RootComponentConstructor,
|
||||
options: Options | None = None,
|
||||
) -> None:
|
||||
"""Configure an application instance to display the given component"""
|
||||
options = options or Options()
|
||||
|
@ -63,7 +65,7 @@ def configure(
|
|||
|
||||
|
||||
# BackendType.create_development_app
|
||||
def create_development_app() -> Sanic:
|
||||
def create_development_app() -> Sanic[Any, Any]:
|
||||
"""Return a :class:`Sanic` app instance in test mode"""
|
||||
Sanic.test_mode = True
|
||||
logger.warning("Sanic.test_mode is now active")
|
||||
|
@ -72,7 +74,7 @@ def create_development_app() -> Sanic:
|
|||
|
||||
# BackendType.serve_development_app
|
||||
async def serve_development_app(
|
||||
app: Sanic,
|
||||
app: Sanic[Any, Any],
|
||||
host: str,
|
||||
port: int,
|
||||
started: asyncio.Event | None = None,
|
||||
|
@ -81,7 +83,7 @@ async def serve_development_app(
|
|||
await serve_with_uvicorn(app, host, port, started)
|
||||
|
||||
|
||||
def use_request() -> request.Request:
|
||||
def use_request() -> request.Request[Any, Any]:
|
||||
"""Get the current ``Request``"""
|
||||
return use_connection().carrier.request
|
||||
|
||||
|
@ -113,7 +115,7 @@ def _setup_common_routes(
|
|||
index_html = read_client_index_html(options)
|
||||
|
||||
async def single_page_app_files(
|
||||
request: request.Request,
|
||||
request: request.Request[Any, Any],
|
||||
_: str = "",
|
||||
) -> response.HTTPResponse:
|
||||
return response.html(index_html)
|
||||
|
@ -131,7 +133,7 @@ def _setup_common_routes(
|
|||
)
|
||||
|
||||
async def asset_files(
|
||||
request: request.Request,
|
||||
request: request.Request[Any, Any],
|
||||
path: str = "",
|
||||
) -> response.HTTPResponse:
|
||||
path = urllib_parse.unquote(path)
|
||||
|
@ -140,7 +142,7 @@ def _setup_common_routes(
|
|||
api_blueprint.add_route(asset_files, f"/{ASSETS_PATH.name}/<path:path>")
|
||||
|
||||
async def web_module_files(
|
||||
request: request.Request,
|
||||
request: request.Request[Any, Any],
|
||||
path: str,
|
||||
_: str = "", # this is not used
|
||||
) -> response.HTTPResponse:
|
||||
|
@ -159,7 +161,9 @@ def _setup_single_view_dispatcher_route(
|
|||
options: Options,
|
||||
) -> None:
|
||||
async def model_stream(
|
||||
request: request.Request, socket: WebSocketConnection, path: str = ""
|
||||
request: request.Request[Any, Any],
|
||||
socket: WebSocketConnection,
|
||||
path: str = "",
|
||||
) -> None:
|
||||
asgi_app = getattr(request.app, "_asgi_app", None)
|
||||
scope = asgi_app.transport.scope if asgi_app else {}
|
||||
|
@ -220,7 +224,7 @@ def _make_send_recv_callbacks(
|
|||
class _SanicCarrier:
|
||||
"""A simple wrapper for holding connection information"""
|
||||
|
||||
request: request.Request
|
||||
request: request.Request[Sanic[Any, Any], Any]
|
||||
"""The current request object"""
|
||||
|
||||
websocket: WebSocketConnection
|
||||
|
|
|
@ -180,7 +180,7 @@ class Layout:
|
|||
old_parent_model = parent.model.current
|
||||
old_parent_children = old_parent_model["children"]
|
||||
parent.model.current = {
|
||||
**old_parent_model, # type: ignore[misc]
|
||||
**old_parent_model,
|
||||
"children": [
|
||||
*old_parent_children[:index],
|
||||
new_state.model.current,
|
||||
|
|
Loading…
Reference in a new issue