labthings-fastapi 0.0.16__tar.gz → 0.0.17__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/PKG-INFO +1 -1
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/pyproject.toml +1 -1
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/base_descriptor.py +47 -32
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/.gitignore +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/LICENSE +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/README.md +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/__init__.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/actions.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/client/__init__.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/client/in_server.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/dependencies/__init__.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/dependencies/blocking_portal.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/dependencies/invocation.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/dependencies/metadata.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/dependencies/raw_thing.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/dependencies/thing.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/dependencies/thing_server.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/deps.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/endpoints.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/example_things/__init__.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/exceptions.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/invocation_contexts.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/invocations.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/logs.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/middleware/__init__.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/middleware/url_for.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/notifications.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/outputs/__init__.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/outputs/blob.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/outputs/mjpeg_stream.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/properties.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/py.typed +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/server/__init__.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/server/cli.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/server/config_model.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/server/fallback.html.jinja +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/server/fallback.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/testing.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/thing.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/thing_description/__init__.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/thing_description/_model.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/thing_description/td-json-schema-validation.json +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/thing_description/validation.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/thing_server_interface.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/thing_slots.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/types/__init__.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/types/numpy.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/utilities/__init__.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/utilities/introspection.py +0 -0
- {labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/websockets.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: labthings-fastapi
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.17
|
|
4
4
|
Summary: An implementation of LabThings using FastAPI
|
|
5
5
|
Project-URL: Homepage, https://github.com/labthings/labthings-fastapi
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/labthings/labthings-fastapi/issues
|
{labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/base_descriptor.py
RENAMED
|
@@ -335,22 +335,6 @@ class BaseDescriptorInfo(
|
|
|
335
335
|
descriptor = self.get_descriptor()
|
|
336
336
|
return descriptor.__get__(self.owning_object_or_error())
|
|
337
337
|
|
|
338
|
-
def set(self, value: Value) -> None:
|
|
339
|
-
"""Set the value of the descriptor.
|
|
340
|
-
|
|
341
|
-
This method may only be called if the DescriptorInfo object is bound to a
|
|
342
|
-
`.Thing` instance. It will raise an error if called on a class.
|
|
343
|
-
|
|
344
|
-
:param value: the new value.
|
|
345
|
-
|
|
346
|
-
:raises NotBoundToInstanceError: if called on an unbound info object.
|
|
347
|
-
"""
|
|
348
|
-
if not self.is_bound:
|
|
349
|
-
msg = f"We can't set the value of {self.name} when called on a class."
|
|
350
|
-
raise NotBoundToInstanceError(msg)
|
|
351
|
-
descriptor = self.get_descriptor()
|
|
352
|
-
descriptor.__set__(self.owning_object_or_error(), value)
|
|
353
|
-
|
|
354
338
|
def __eq__(self, other: Any) -> bool:
|
|
355
339
|
"""Determine if this object is equal to another one.
|
|
356
340
|
|
|
@@ -404,6 +388,11 @@ class BaseDescriptor(Generic[Owner, Value]):
|
|
|
404
388
|
assert p.name == "my_prop"
|
|
405
389
|
assert p.title == "My Property."
|
|
406
390
|
assert p.description.startswith("This is")
|
|
391
|
+
|
|
392
|
+
`.BaseDescriptor` is a "non-data descriptor" (meaning it doesn't implement
|
|
393
|
+
``__set__``). This allows it to be overwritten by assigning to an object's
|
|
394
|
+
attribute, which can be useful in test code. This can easily be changed in
|
|
395
|
+
subclasses by implementing ``__set__``\ .
|
|
407
396
|
"""
|
|
408
397
|
|
|
409
398
|
def __init__(self) -> None:
|
|
@@ -593,21 +582,6 @@ class BaseDescriptor(Generic[Owner, Value]):
|
|
|
593
582
|
"See BaseDescriptor.__instance_get__ for details."
|
|
594
583
|
)
|
|
595
584
|
|
|
596
|
-
def __set__(self, obj: Owner, value: Value) -> None:
|
|
597
|
-
"""Mark the `BaseDescriptor` as a data descriptor.
|
|
598
|
-
|
|
599
|
-
Even for read-only descriptors, it's important to define a ``__set__`` method.
|
|
600
|
-
The presence of this method prevents Python overwriting the descriptor when
|
|
601
|
-
a value is assigned. This base implementation returns an `AttributeError` to
|
|
602
|
-
signal that the descriptor is read-only. Overriding it with a method that
|
|
603
|
-
does not raise an exception will allow the descriptor to be written to.
|
|
604
|
-
|
|
605
|
-
:param obj: The object on which to set the value.
|
|
606
|
-
:param value: The value to set the descriptor to.
|
|
607
|
-
:raises AttributeError: always, as this is read-only by default.
|
|
608
|
-
"""
|
|
609
|
-
raise AttributeError("This attribute is read-only.")
|
|
610
|
-
|
|
611
585
|
def _descriptor_info(
|
|
612
586
|
self, info_class: type[DescriptorInfoT], obj: Owner | None = None
|
|
613
587
|
) -> DescriptorInfoT:
|
|
@@ -669,9 +643,35 @@ class FieldTypedBaseDescriptorInfo(
|
|
|
669
643
|
"""The type of the descriptor's value."""
|
|
670
644
|
return self.get_descriptor().value_type
|
|
671
645
|
|
|
646
|
+
def set(self, value: Value) -> None:
|
|
647
|
+
"""Set the value of the descriptor.
|
|
648
|
+
|
|
649
|
+
This method may only be called if the DescriptorInfo object is bound to a
|
|
650
|
+
`.Thing` instance. It will raise an error if called on a class.
|
|
651
|
+
|
|
652
|
+
:param value: the new value.
|
|
653
|
+
|
|
654
|
+
:raises NotBoundToInstanceError: if called on an unbound info object.
|
|
655
|
+
"""
|
|
656
|
+
if not self.is_bound:
|
|
657
|
+
msg = f"We can't set the value of {self.name} when called on a class."
|
|
658
|
+
raise NotBoundToInstanceError(msg)
|
|
659
|
+
descriptor = self.get_descriptor()
|
|
660
|
+
descriptor.__set__(self.owning_object_or_error(), value)
|
|
661
|
+
|
|
672
662
|
|
|
673
663
|
class FieldTypedBaseDescriptor(Generic[Owner, Value], BaseDescriptor[Owner, Value]):
|
|
674
|
-
"""A BaseDescriptor that determines its type like a dataclass field.
|
|
664
|
+
r"""A `.BaseDescriptor` that determines its type like a dataclass field.
|
|
665
|
+
|
|
666
|
+
This adds two things to `.BaseDescriptor`\ :
|
|
667
|
+
|
|
668
|
+
1. Descriptors inheriting from this class will inspect the type annotations of
|
|
669
|
+
their owning class when determining ``value_type``\ .
|
|
670
|
+
2. This class and its children will be "data descriptors" because there is a
|
|
671
|
+
stub implementation of ``__set__``\ . This means that the attribute may not
|
|
672
|
+
be assigned to (unless ``__set__`` is overridden). This is the behaviour
|
|
673
|
+
that `builtins.property` has.
|
|
674
|
+
"""
|
|
675
675
|
|
|
676
676
|
def __init__(self) -> None:
|
|
677
677
|
"""Initialise the FieldTypedBaseDescriptor.
|
|
@@ -852,6 +852,21 @@ class FieldTypedBaseDescriptor(Generic[Owner, Value], BaseDescriptor[Owner, Valu
|
|
|
852
852
|
"""
|
|
853
853
|
return self._descriptor_info(FieldTypedBaseDescriptorInfo, owner)
|
|
854
854
|
|
|
855
|
+
def __set__(self, obj: Owner, value: Value) -> None:
|
|
856
|
+
"""Mark the `BaseDescriptor` as a data descriptor.
|
|
857
|
+
|
|
858
|
+
Even for read-only descriptors, it's important to define a ``__set__`` method.
|
|
859
|
+
The presence of this method prevents Python overwriting the descriptor when
|
|
860
|
+
a value is assigned. This base implementation returns an `AttributeError` to
|
|
861
|
+
signal that the descriptor is read-only. Overriding it with a method that
|
|
862
|
+
does not raise an exception will allow the descriptor to be written to.
|
|
863
|
+
|
|
864
|
+
:param obj: The object on which to set the value.
|
|
865
|
+
:param value: The value to set the descriptor to.
|
|
866
|
+
:raises AttributeError: always, as this is read-only by default.
|
|
867
|
+
"""
|
|
868
|
+
raise AttributeError("This attribute is read-only.")
|
|
869
|
+
|
|
855
870
|
|
|
856
871
|
class DescriptorInfoCollection(
|
|
857
872
|
Mapping[str, DescriptorInfoT],
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/client/__init__.py
RENAMED
|
File without changes
|
{labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/client/in_server.py
RENAMED
|
File without changes
|
{labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/dependencies/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/dependencies/metadata.py
RENAMED
|
File without changes
|
|
File without changes
|
{labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/dependencies/thing.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/invocation_contexts.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/middleware/__init__.py
RENAMED
|
File without changes
|
{labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/middleware/url_for.py
RENAMED
|
File without changes
|
{labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/notifications.py
RENAMED
|
File without changes
|
{labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/outputs/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/outputs/mjpeg_stream.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/server/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/server/config_model.py
RENAMED
|
File without changes
|
|
File without changes
|
{labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/server/fallback.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/types/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{labthings_fastapi-0.0.16 → labthings_fastapi-0.0.17}/src/labthings_fastapi/utilities/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|