Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add types and remove unused imports #170

Merged
merged 1 commit into from
Dec 10, 2024
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
1 change: 0 additions & 1 deletion capellambse_context_diagrams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from __future__ import annotations

import collections.abc as cabc
import logging
import typing as t
from importlib import metadata
Expand Down
8 changes: 7 additions & 1 deletion capellambse_context_diagrams/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
The pre-layouted data was collected with the functions from
[collectors][capellambse_context_diagrams.collectors].
"""

from __future__ import annotations

import collections.abc as cabc
Expand All @@ -15,6 +16,7 @@
import typing as t

from capellambse import diagram as cdiagram
from capellambse import model as m
from capellambse.svg import decorations

from . import _elkjs, context
Expand Down Expand Up @@ -303,12 +305,16 @@ def get_styleclass(self, uuid: str) -> str | None:
[`_elkjs.ELKOutputChild`][capellambse_context_diagrams._elkjs.ELKOutputChild].
"""
try:
melodyobj = self._diagram._model.by_uuid(uuid)
melodyobj: m.ModelElement | m.Diagram = (
self._diagram._model.by_uuid(uuid)
)
except KeyError:
if not uuid.startswith("__"):
return None
return uuid[2:].split(":", 1)[0]
else:
if isinstance(melodyobj, m.Diagram):
return melodyobj.type.value
return melodyobj._get_styleclass()

def get_styleoverrides(
Expand Down
Loading