Skip to content
Snippets Groups Projects

Bump Python requirement mkdocs-material to 9.5.2

Merged Teklia Bot requested to merge bump-mkdocs-material into master
Files
24
@@ -86,8 +86,9 @@ class ElementMixin:
element: Element,
type: str,
name: str,
polygon: list[list[int | float]],
polygon: list[list[int | float]] | None = None,
confidence: float | None = None,
image: str | None = None,
slim_output: bool = True,
) -> str:
"""
@@ -96,8 +97,10 @@ class ElementMixin:
:param Element element: The parent element.
:param type: Slug of the element type for this child element.
:param name: Name of the child element.
:param polygon: Polygon of the child element.
:param polygon: Optional polygon of the child element.
:param confidence: Optional confidence score, between 0.0 and 1.0.
:param image: Optional image ID of the child element.
:param slim_output: Whether to return the child ID or the full child.
:returns: UUID of the created element.
"""
assert element and isinstance(
@@ -109,19 +112,29 @@ class ElementMixin:
assert name and isinstance(
name, str
), "name shouldn't be null and should be of type str"
assert polygon and isinstance(
assert polygon is None or isinstance(
polygon, list
), "polygon shouldn't be null and should be of type list"
assert len(polygon) >= 3, "polygon should have at least three points"
assert all(
isinstance(point, list) and len(point) == 2 for point in polygon
), "polygon points should be lists of two items"
assert all(
isinstance(coord, int | float) for point in polygon for coord in point
), "polygon points should be lists of two numbers"
), "polygon should be None or a list"
if polygon is not None:
assert len(polygon) >= 3, "polygon should have at least three points"
assert all(
isinstance(point, list) and len(point) == 2 for point in polygon
), "polygon points should be lists of two items"
assert all(
isinstance(coord, int | float) for point in polygon for coord in point
), "polygon points should be lists of two numbers"
assert confidence is None or (
isinstance(confidence, float) and 0 <= confidence <= 1
), "confidence should be None or a float in [0..1] range"
assert image is None or isinstance(image, str), "image should be None or string"
if image is not None:
# Make sure it's a valid UUID
try:
UUID(image)
except ValueError as e:
raise ValueError("image is not a valid uuid.") from e
if polygon and image is None:
assert element.zone, "An image or a parent with an image is required to create an element with a polygon."
assert isinstance(slim_output, bool), "slim_output should be of type bool"
if self.is_read_only:
@@ -133,7 +146,7 @@ class ElementMixin:
body={
"type": type,
"name": name,
"image": element.zone.image.id,
"image": image,
"corpus": element.corpus.id,
"polygon": polygon,
"parent": element.id,
@@ -270,6 +283,35 @@ class ElementMixin:
return created_ids
def create_element_parent(
self,
parent: Element,
child: Element,
) -> dict[str, str]:
"""
Link an element to a parent through the API.
:param parent: Parent element.
:param child: Child element.
:returns: A dict from the ``CreateElementParent`` API endpoint.
"""
assert parent and isinstance(
parent, Element
), "parent shouldn't be null and should be of type Element"
assert child and isinstance(
child, Element
), "child shouldn't be null and should be of type Element"
if self.is_read_only:
logger.warning("Cannot link elements as this worker is in read-only mode")
return
return self.request(
"CreateElementParent",
parent=parent.id,
child=child.id,
)
def partial_update_element(
self, element: Element | CachedElement, **kwargs
) -> dict:
@@ -288,7 +330,7 @@ class ElementMixin:
* *image* (``UUID``): Optional ID of the image of this element
:returns: A dict from the ``PartialUpdateElement`` API endpoint,
:returns: A dict from the ``PartialUpdateElement`` API endpoint.
"""
assert element and isinstance(
element, Element | CachedElement
Loading