Skip to content

Commit 7e07ca2

Browse files
committed
Format fixes
1 parent 2d5c80f commit 7e07ca2

25 files changed

+58
-46
lines changed

docs/source/conf.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,38 @@
66
# -- Project information -----------------------------------------------------
77
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
88

9-
project = 'labthings-fastapi'
10-
copyright = '2024, Richard Bowman'
11-
author = 'Richard Bowman'
12-
release = '0.0.1'
9+
project = "labthings-fastapi"
10+
copyright = "2024, Richard Bowman"
11+
author = "Richard Bowman"
12+
release = "0.0.1"
1313

1414
# -- General configuration ---------------------------------------------------
1515
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
1616

1717
extensions = [
1818
"myst_parser",
1919
"sphinx.ext.intersphinx",
20-
#"sphinx.ext.napoleon",
20+
# "sphinx.ext.napoleon",
2121
"autodoc2",
2222
"sphinx_rtd_theme",
2323
]
2424

25-
templates_path = ['_templates']
25+
templates_path = ["_templates"]
2626
exclude_patterns = []
2727

2828
autodoc2_packages = ["../../src/labthings_fastapi"]
2929
autodoc2_render_plugin = "myst"
3030

31-
#autoapi_dirs = ["../../src/labthings_fastapi"]
32-
#autoapi_ignore = []
33-
#autoapi_generate_api_docs = True
34-
#autoapi_keep_files = True
31+
# autoapi_dirs = ["../../src/labthings_fastapi"]
32+
# autoapi_ignore = []
33+
# autoapi_generate_api_docs = True
34+
# autoapi_keep_files = True
3535

3636
# -- Options for HTML output -------------------------------------------------
3737
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
3838

39-
html_theme = 'sphinx_rtd_theme'
40-
html_static_path = ['_static']
39+
html_theme = "sphinx_rtd_theme"
40+
html_static_path = ["_static"]
4141

4242
intersphinx_mapping = {
4343
"python": ("https://docs.python.org/3", None),

src/labthings_fastapi/client/in_server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
This module may get moved in the near future.
88
99
"""
10+
1011
from __future__ import annotations
1112
from functools import wraps
1213
import inspect

src/labthings_fastapi/decorators/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
1010
If you have a complex datatype, it's recommended to use a `pydantic` model
1111
to describe it - this is often the case for complicated properties or events.
12-
For actions, a model is created automatically based on the function's
12+
For actions, a model is created automatically based on the function's
1313
signature: if you want to add descriptions or validators to individual
1414
arguments, you may use `pydantic.Field` to do this.
1515

src/labthings_fastapi/dependencies/blocking_portal.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
This allows dependencies that are called by threaded code to send things back
44
to the async event loop.
55
"""
6+
67
from __future__ import annotations
78
from typing import Annotated
89
from fastapi import Depends, Request
@@ -30,4 +31,4 @@ def blocking_portal_from_thing_server(request: Request) -> RealBlockingPortal:
3031
type `BlockingPortal`, FastAPI will automatically inject the blocking portal.
3132
This is simply shorthand for {class}`anyio.from_thread.BlockingPortal` annotated with
3233
`Depends(blocking_portal_from_thing_server)`.
33-
"""
34+
"""

src/labthings_fastapi/dependencies/invocation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""FastAPI dependency for an invocation ID"""
2+
23
from __future__ import annotations
34
import uuid
45
from typing import Annotated

src/labthings_fastapi/dependencies/raw_thing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def raw_thing_dependency(cls: type[ThingInstance]) -> type[ThingInstance]:
6363
prompts FastAPI to supply the instance of the class.
6464
6565
Usage:
66-
66+
6767
```{code-block} python
6868
6969
from my_other_thing import MyOtherThing as MyOtherThingClass

src/labthings_fastapi/dependencies/thing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import annotations
2-
from typing import Annotated, Optional, TypeVar
2+
from typing import Annotated, Optional
33

44
from fastapi import Depends
55

@@ -13,13 +13,13 @@ def direct_thing_client_dependency(
1313
actions: Optional[list[str]] = None,
1414
) -> type[Thing]:
1515
"""A type annotation that causes FastAPI to supply a direct thing client
16-
16+
1717
:param thing_class: The class of the thing to connect to
1818
:param thing_path: The path to the thing on the server
19-
:param actions: The actions that the client should be able to perform.
19+
:param actions: The actions that the client should be able to perform.
2020
If this is specified, only those actions will be available. If it is
2121
`None` (default), all actions will be available.
22-
22+
2323
Note that the dependencies of all available actions will be added to
2424
your endpoint - so it is best to only specify the actions you need, in
2525
order to avoid spurious extra dependencies.

src/labthings_fastapi/descriptors/action.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
"""
22
Define an object to represent an Action, as a descriptor.
33
"""
4+
45
from __future__ import annotations
56
from functools import partial
67
import inspect
7-
from typing import TYPE_CHECKING, Annotated, Any, Callable, Optional, Literal, Union, overload
8+
from typing import (
9+
TYPE_CHECKING,
10+
Annotated,
11+
Any,
12+
Callable,
13+
Optional,
14+
Literal,
15+
Union,
16+
overload,
17+
)
818
from fastapi import Body, FastAPI, Request, BackgroundTasks
919
from pydantic import create_model
1020
from ..actions import InvocationModel
@@ -75,12 +85,10 @@ def __init__(
7585
self.invocation_model.__name__ = f"{self.name}_invocation"
7686

7787
@overload
78-
def __get__(self, obj: Literal[None], type=None) -> ActionDescriptor:
79-
...
88+
def __get__(self, obj: Literal[None], type=None) -> ActionDescriptor: ...
8089

8190
@overload
82-
def __get__(self, obj: Thing, type=None) -> Callable:
83-
...
91+
def __get__(self, obj: Thing, type=None) -> Callable: ...
8492

8593
def __get__(
8694
self, obj: Optional[Thing], type=None

src/labthings_fastapi/descriptors/endpoint.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,10 @@ def __init__(
3737
self.kwargs = kwargs
3838

3939
@overload
40-
def __get__(self, obj: Literal[None], type=None) -> Self:
41-
...
40+
def __get__(self, obj: Literal[None], type=None) -> Self: ...
4241

4342
@overload
44-
def __get__(self, obj: Thing, type=None) -> Callable:
45-
...
43+
def __get__(self, obj: Thing, type=None) -> Callable: ...
4644

4745
def __get__(self, obj: Optional[Thing], type=None) -> Union[Self, Callable]:
4846
"""The function, bound to an object as for a normal method.

src/labthings_fastapi/descriptors/property.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Define an object to represent an Action, as a descriptor.
33
"""
4+
45
from __future__ import annotations
56
from typing import TYPE_CHECKING, Annotated, Any, Callable, Optional
67
from typing_extensions import Self

src/labthings_fastapi/file_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
handle finding a temporary storage location, and making it possible to retrieve the
99
files via the Invocation object.
1010
"""
11+
1112
from __future__ import annotations
1213
from tempfile import TemporaryDirectory
1314
from typing import Annotated, Sequence, Optional

src/labthings_fastapi/notifications.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
enables property changes to be fed via a websocket. Events proper should
1313
not be a big step thereafter.
1414
15-
Currently, this code is more or less all in `websockets.py` and
15+
Currently, this code is more or less all in `websockets.py` and
1616
`descriptors/property.py` but it should get consolidated.
1717
"""
1818

19-
2019
from __future__ import annotations
2120

2221

src/labthings_fastapi/outputs/blob.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,15 @@ def media_type(self) -> str:
4444
def content(self) -> bytes:
4545
pass
4646

47-
def save(self, filename: str) -> None:
48-
...
47+
def save(self, filename: str) -> None: ...
4948

50-
def open(self) -> io.IOBase:
51-
...
49+
def open(self) -> io.IOBase: ...
5250

5351

5452
class ServerSideBlobOutputProtocol(BlobOutputProtocol, Protocol):
5553
"""A BlobOutput protocol for server-side use, i.e. including `response()`"""
5654

57-
def response(self) -> Response:
58-
...
55+
def response(self) -> Response: ...
5956

6057

6158
def is_blob_output(obj: Any) -> bool:

src/labthings_fastapi/outputs/mjpeg_stream.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def stop(self):
9292

9393
async def ringbuffer_entry(self, i: int) -> RingbufferEntry:
9494
"""Return the ith frame acquired by the camera
95-
95+
9696
:param i: The index of the frame to read
9797
"""
9898
if i < 0:
@@ -110,7 +110,7 @@ async def ringbuffer_entry(self, i: int) -> RingbufferEntry:
110110
@asynccontextmanager
111111
async def buffer_for_reading(self, i: int) -> AsyncIterator[bytes]:
112112
"""Yields the ith frame as a bytes object
113-
113+
114114
:param i: The index of the frame to read
115115
"""
116116
entry = await self.ringbuffer_entry(i)
@@ -158,7 +158,7 @@ async def mjpeg_stream_response(self) -> MJPEGStreamResponse:
158158

159159
def add_frame(self, frame: bytes, portal: BlockingPortal):
160160
"""Return the next buffer in the ringbuffer to write to
161-
161+
162162
:param frame: The frame to add
163163
:param portal: The blocking portal to use for scheduling tasks.
164164
This is necessary because tasks are handled asynchronously.
@@ -191,12 +191,10 @@ def __set_name__(self, owner, name):
191191
self.name = name
192192

193193
@overload
194-
def __get__(self, obj: Literal[None], type=None) -> Self:
195-
...
194+
def __get__(self, obj: Literal[None], type=None) -> Self: ...
196195

197196
@overload
198-
def __get__(self, obj: Thing, type=None) -> MJPEGStream:
199-
...
197+
def __get__(self, obj: Thing, type=None) -> MJPEGStream: ...
200198

201199
def __get__(self, obj: Optional[Thing], type=None) -> Union[MJPEGStream, Self]:
202200
"""The value of the property

src/labthings_fastapi/thing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
The `Thing` class enables most of the functionality of this library,
33
and is the way in to most of its features. In the future, we might
44
support a stub version of the class in a separate package, so
5-
that instrument control libraries can be LabThings compatible
5+
that instrument control libraries can be LabThings compatible
66
without a hard dependency on LabThings. But that is something we
77
will do in the future...
88
"""

src/labthings_fastapi/thing_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ async def lifespan(self, app: FastAPI):
9494
"""Manage set up and tear down
9595
9696
This does two important things:
97-
97+
9898
* It sets up the blocking portal so background threads can run async code
9999
(important for events)
100100
* It runs setup/teardown code for Things.

src/labthings_fastapi/thing_settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
ThingSettings is a dictionary-like object that manages settings for one Thing
55
"""
6+
67
from __future__ import annotations
78
import json
89
import os

src/labthings_fastapi/types/numpy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def double(arr: NDArray) -> NDArray:
1717
1818
Complex numbers are currently not supported, again this is left for the future.
1919
"""
20+
2021
from __future__ import annotations
2122
import numpy as np
2223
from pydantic import (

src/labthings_fastapi/websockets.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
(c) Richard Bowman July 2023, released under GNU-LGPL-3.0
2020
"""
2121

22-
2322
from __future__ import annotations
2423
from anyio import create_memory_object_stream, create_task_group
2524
from anyio.abc import ObjectReceiveStream, ObjectSendStream

tests/test_action_cancel.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
This tests the log that is returned in an action invocation
33
"""
4+
45
import uuid
56
from fastapi.testclient import TestClient
67
from labthings_fastapi.thing_server import ThingServer

tests/test_action_logging.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
This tests the log that is returned in an action invocation
33
"""
4+
45
import logging
56
from fastapi.testclient import TestClient
67
from labthings_fastapi.thing_server import ThingServer

tests/test_blob_output.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
This tests Things that depend on other Things
33
"""
4+
45
import os
56
from tempfile import TemporaryDirectory
67
from fastapi.testclient import TestClient

tests/test_dependencies_2.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
test things from FastAPI that obviously work, but I will leave them in here as
1414
mitigation against something changing in the future.
1515
"""
16+
1617
from typing import Annotated
1718
from fastapi import Depends, FastAPI
1819
from fastapi.testclient import TestClient

tests/test_dependency_metadata.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
This tests metadata retrieval, as used by e.g. the camera for EXIF info
33
"""
4+
45
from typing import Any, Mapping
56
from fastapi.testclient import TestClient
67
from labthings_fastapi.thing_server import ThingServer

tests/test_thing_dependencies.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
This tests Things that depend on other Things
33
"""
4+
45
import inspect
56
from fastapi.testclient import TestClient
67
from fastapi import Request

0 commit comments

Comments
 (0)