Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/labthings_fastapi/outputs/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@
if self.href == "blob://local":
if self._data:
return self
raise ValueError("Blob objects must have data if the href is blob://local")

Check warning on line 369 in src/labthings_fastapi/outputs/blob.py

View workflow job for this annotation

GitHub Actions / coverage

369 line is not covered with tests
try:
url_to_blobdata = url_to_blobdata_ctx.get()
self._data = url_to_blobdata(self.href)
Expand Down Expand Up @@ -452,7 +452,7 @@
:raise ValueError: if there is no data stored on disk or in memory.
"""
if self._data is None:
raise ValueError("This Blob has no data.")

Check warning on line 455 in src/labthings_fastapi/outputs/blob.py

View workflow job for this annotation

GitHub Actions / coverage

455 line is not covered with tests
return self._data

@property
Expand Down Expand Up @@ -571,7 +571,7 @@

:return: an HTTP response that streams data from memory or file.
"""
return self.data.response()

Check warning on line 574 in src/labthings_fastapi/outputs/blob.py

View workflow job for this annotation

GitHub Actions / coverage

574 line is not covered with tests


def blob_type(media_type: str) -> type[Blob]:
Expand Down Expand Up @@ -657,7 +657,7 @@
if blob.id in self._blobs:
return blob.id
else:
raise ValueError(

Check warning on line 660 in src/labthings_fastapi/outputs/blob.py

View workflow job for this annotation

GitHub Actions / coverage

660 line is not covered with tests
f"BlobData already has an ID {blob.id} "
"but was not found in this BlobDataManager"
)
Expand Down Expand Up @@ -730,7 +730,7 @@

async def blob_serialisation_context_manager(
request: Request,
) -> AsyncGenerator[BlobDataManager]:
) -> AsyncGenerator[BlobDataManager, None]:
r"""Set context variables to allow blobs to be [de]serialised.

In order to serialise a `.Blob` to a JSON-serialisable dictionary, we must
Expand Down
2 changes: 1 addition & 1 deletion src/labthings_fastapi/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
instances = self.things_by_class(cls)
if len(instances) == 1:
return instances[0]
raise RuntimeError(

Check warning on line 167 in src/labthings_fastapi/server/__init__.py

View workflow job for this annotation

GitHub Actions / coverage

167 line is not covered with tests
f"There are {len(instances)} Things of class {cls}, expected 1."
)

Expand Down Expand Up @@ -241,7 +241,7 @@
thing.attach_to_server(self)

@asynccontextmanager
async def lifespan(self, app: FastAPI) -> AsyncGenerator[None]:
async def lifespan(self, app: FastAPI) -> AsyncGenerator[None, None]:
"""Manage set up and tear down of the server and Things.

This method is used as a lifespan function for the FastAPI app. See
Expand Down Expand Up @@ -300,7 +300,7 @@
are `pydantic.BaseModel` subclasses that get serialised to
dictionaries.
"""
return {

Check warning on line 303 in src/labthings_fastapi/server/__init__.py

View workflow job for this annotation

GitHub Actions / coverage

303 line is not covered with tests
path: thing.thing_description(path, base=str(request.base_url))
for path, thing in thing_server.things.items()
}
Expand All @@ -314,7 +314,7 @@
:return: a list of paths pointing to `.Thing` instances. These
URLs will return the :ref:`wot_td` of one `.Thing` each.
""" # noqa: D403 (URLs is correct capitalisation)
return {

Check warning on line 317 in src/labthings_fastapi/server/__init__.py

View workflow job for this annotation

GitHub Actions / coverage

317 line is not covered with tests
t: f"{str(request.base_url).rstrip('/')}{t}"
for t in thing_server.things.keys()
}