chore: lint
This commit is contained in:
@@ -24,7 +24,7 @@ __all__ = [
|
|||||||
"extension_api_method",
|
"extension_api_method",
|
||||||
"get_extension_api_method",
|
"get_extension_api_method",
|
||||||
"invoke_wasm_extension_export",
|
"invoke_wasm_extension_export",
|
||||||
"load_wasm_extension",
|
|
||||||
"list_extension_api_methods",
|
"list_extension_api_methods",
|
||||||
|
"load_wasm_extension",
|
||||||
"register_wasm_extension",
|
"register_wasm_extension",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -93,9 +93,7 @@ def extension_api_method(
|
|||||||
function: Callable[[ExtensionAPI, _RequestModel], Awaitable[_ResponseModel]],
|
function: Callable[[ExtensionAPI, _RequestModel], Awaitable[_ResponseModel]],
|
||||||
) -> Callable[[ExtensionAPI, _RequestModel], Awaitable[_ResponseModel]]:
|
) -> Callable[[ExtensionAPI, _RequestModel], Awaitable[_ResponseModel]]:
|
||||||
@wraps(function)
|
@wraps(function)
|
||||||
async def wrapper(
|
async def wrapper(self: ExtensionAPI, request: _RequestModel) -> _ResponseModel:
|
||||||
self: ExtensionAPI, request: _RequestModel
|
|
||||||
) -> _ResponseModel:
|
|
||||||
self.require_permission(required_permission)
|
self.require_permission(required_permission)
|
||||||
return await function(self, request)
|
return await function(self, request)
|
||||||
|
|
||||||
|
|||||||
@@ -207,9 +207,7 @@ def _wasm_extension_api_export(extension: WasmExtension, export_name: Any) -> st
|
|||||||
continue
|
continue
|
||||||
if export.get("visibility") in {"public", "authenticated"}:
|
if export.get("visibility") in {"public", "authenticated"}:
|
||||||
return export_name
|
return export_name
|
||||||
raise PermissionError(
|
raise PermissionError(f"WASM export '{export_name}' is not callable over HTTP.")
|
||||||
f"WASM export '{export_name}' is not callable over HTTP."
|
|
||||||
)
|
|
||||||
raise KeyError(f"WASM extension '{extension.id}' has no export '{export_name}'.")
|
raise KeyError(f"WASM extension '{extension.id}' has no export '{export_name}'.")
|
||||||
|
|
||||||
|
|
||||||
@@ -301,7 +299,9 @@ def _wasm_extension_route_path(extension: WasmExtension, path: Any) -> str:
|
|||||||
|
|
||||||
def _wasm_extension_entrypoint(extension: WasmExtension, entrypoint: Any) -> Path:
|
def _wasm_extension_entrypoint(extension: WasmExtension, entrypoint: Any) -> Path:
|
||||||
if not isinstance(entrypoint, str) or not entrypoint.startswith("/"):
|
if not isinstance(entrypoint, str) or not entrypoint.startswith("/"):
|
||||||
raise ValueError(f"Invalid route entrypoint for WASM extension '{extension.id}'.")
|
raise ValueError(
|
||||||
|
f"Invalid route entrypoint for WASM extension '{extension.id}'."
|
||||||
|
)
|
||||||
|
|
||||||
static_prefix = f"/{extension.id}/static/"
|
static_prefix = f"/{extension.id}/static/"
|
||||||
if not entrypoint.startswith(static_prefix):
|
if not entrypoint.startswith(static_prefix):
|
||||||
@@ -310,7 +310,7 @@ def _wasm_extension_entrypoint(extension: WasmExtension, entrypoint: Any) -> Pat
|
|||||||
f"'{static_prefix}'."
|
f"'{static_prefix}'."
|
||||||
)
|
)
|
||||||
|
|
||||||
path = (extension.root_path / "static" / entrypoint.removeprefix(static_prefix))
|
path = extension.root_path / "static" / entrypoint.removeprefix(static_prefix)
|
||||||
path = path.resolve()
|
path = path.resolve()
|
||||||
if extension.root_path.resolve() not in path.parents:
|
if extension.root_path.resolve() not in path.parents:
|
||||||
raise ValueError(f"Route entrypoint escapes extension root: {entrypoint}")
|
raise ValueError(f"Route entrypoint escapes extension root: {entrypoint}")
|
||||||
|
|||||||
@@ -65,7 +65,9 @@ def _invoke_wasm_extension_export_sync(
|
|||||||
instance = linker.instantiate(store, wasm_component)
|
instance = linker.instantiate(store, wasm_component)
|
||||||
function = instance.get_func(store, export_name)
|
function = instance.get_func(store, export_name)
|
||||||
if not function:
|
if not function:
|
||||||
raise KeyError(f"WASM extension '{extension.id}' has no export '{export_name}'.")
|
raise KeyError(
|
||||||
|
f"WASM extension '{extension.id}' has no export '{export_name}'."
|
||||||
|
)
|
||||||
|
|
||||||
result = function(store, json.dumps(payload))
|
result = function(store, json.dumps(payload))
|
||||||
function.post_return(store)
|
function.post_return(store)
|
||||||
|
|||||||
Reference in New Issue
Block a user