diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ff5b5be..d6ce14f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ ci: repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.16.0 + rev: v0.16.6 hooks: - id: ruff-check args: ["--fix"] diff --git a/docs/usage/backend.md b/docs/usage/backend.md index 91fa2aa..5227bab 100644 --- a/docs/usage/backend.md +++ b/docs/usage/backend.md @@ -220,8 +220,7 @@ from the adapter: # example_host @backend_class class Neighborhood: - def __init__(self, data, *, n_neighbors=15): - ... + def __init__(self, data, *, n_neighbors=15): ... ``` ```python diff --git a/docs/usage/host.md b/docs/usage/host.md index 92493bb..d8a6a0a 100644 --- a/docs/usage/host.md +++ b/docs/usage/host.md @@ -60,7 +60,7 @@ independently in the same process. distributions, use `distributions`: ```python - trusted_backends={ + trusted_backends = { "example_accel": { "aliases": ["example", "accelerated"], "package": "example-host-accel", @@ -112,6 +112,7 @@ supported. # example_host/analysis.py from example_host._backends import backend_dispatch + @backend_dispatch def compute_score(data, *, method="fast", n_jobs=None, copy=False): """Compute a score. @@ -157,6 +158,7 @@ another decorator that generates the constructor or modifies the class. # example_host/models.py from example_host._backends import backend_class + @backend_class class Neighborhood: def __init__(self, data, *, n_neighbors=15): @@ -175,9 +177,9 @@ class Neighborhood: Construction follows the same selection order as function dispatch: ```python -Neighborhood(data) # active setting, CPU by default -Neighborhood(data, backend="example") # backend class for this instance -Neighborhood(data, backend="cpu") # host class for this instance +Neighborhood(data) # active setting, CPU by default +Neighborhood(data, backend="example") # backend class for this instance +Neighborhood(data, backend="cpu") # host class for this instance ``` The `backend` selector is consumed by the decorator and is not forwarded to @@ -235,6 +237,7 @@ _b._dispatcher.discover() # so autodoc sees merged signatures ```python # in IDE startup, test setup, or anywhere else that introspects: from example_host._backends import _dispatcher + _dispatcher.discover() ```