Skip to content

Commit

Permalink
Merge pull request #5 from DSD-DBS/remove-setup.cfg
Browse files Browse the repository at this point in the history
Update build infrastructure and fix type errors
  • Loading branch information
ewuerger authored Jul 19, 2022
2 parents fc87120 + 202284e commit 5e57ca8
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 123 deletions.
7 changes: 7 additions & 0 deletions capellambse_context_diagrams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@
from __future__ import annotations

import logging
from importlib import metadata

from . import context

try:
__version__ = metadata.version("capellambse-context-diagrams")
except metadata.PackageNotFoundError:
__version__ = "0.0.0+unknown"
del metadata

logger = logging.getLogger(__name__)

ATTR_NAME = "context_diagram"
Expand Down
21 changes: 16 additions & 5 deletions capellambse_context_diagrams/_elkjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,16 @@ class ELKOutputNode(t.TypedDict):
size: ELKSize


class ELKOutputJunction(t.TypedDict):
"""Exchange-Junction that comes out of ELK."""

id: str
type: t.Literal["junction"]

position: ELKPoint
size: ELKSize


class ELKOutputPort(t.TypedDict):
"""Port that comes out of ELK."""

Expand Down Expand Up @@ -187,12 +197,13 @@ class ELKOutputEdge(t.TypedDict):


ELKOutputChild = t.Union[ # type: ignore
ELKOutputNode, ELKOutputPort, ELKOutputLabel, ELKOutputEdge
ELKOutputEdge,
ELKOutputJunction,
ELKOutputLabel,
ELKOutputNode,
ELKOutputPort,
]
"""
Type alias for `ELKOutputNode`, `ELKOutputPort`, `ELKOutputLabel` or
`ELKOutputEdge`.
"""
"""Type alias for ELK output."""


class NodeJSError(RuntimeError):
Expand Down
2 changes: 1 addition & 1 deletion capellambse_context_diagrams/collectors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


def get_elkdata(
diagram: context.ContextDiagram, params: dict[str, t.Any] = None
diagram: context.ContextDiagram, params: dict[str, t.Any] | None = None
) -> _elkjs.ELKInputData:
"""
High level collector function to collect needed data for ELK
Expand Down
2 changes: 1 addition & 1 deletion capellambse_context_diagrams/collectors/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


def collector(
diagram: context.ContextDiagram, params: dict[str, t.Any] = None
diagram: context.ContextDiagram, params: dict[str, t.Any] | None = None
) -> _elkjs.ELKInputData:
"""Collect context data from ports of centric box."""
data = generic.collector(diagram)
Expand Down
2 changes: 1 addition & 1 deletion capellambse_context_diagrams/collectors/portless.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


def collector(
diagram: context.ContextDiagram, params: dict[str, t.Any] = None
diagram: context.ContextDiagram, params: dict[str, t.Any] | None = None
) -> _elkjs.ELKInputData:
"""Collect context data from exchanges of centric box.
Expand Down
8 changes: 4 additions & 4 deletions capellambse_context_diagrams/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def deserialize_child(
[`aird.Diagram`][capellambse.aird.diagram.Diagram] : Diagram
class type that stores all previously named classes.
"""
styleclass: str | None = self.get_styleclass(child)
styleclass: str | None = self.get_styleclass(child["id"])
element: aird.Box | aird.Edge
if child["type"] in {"node", "port"}:
assert parent is None or isinstance(parent, aird.Box)
Expand Down Expand Up @@ -184,7 +184,7 @@ class type that stores all previously named classes.
aird.Vector2D(**child["position"]),
5,
uuid=child["id"],
styleclass=self.get_styleclass({"id": uuid}),
styleclass=self.get_styleclass(uuid),
styleoverrides=self.get_styleoverrides(child),
)
self.aird_diagram.add_element(element)
Expand All @@ -195,13 +195,13 @@ class type that stores all previously named classes.
for i in child.get("children", []): # type: ignore
self.deserialize_child(i, ref, element)

def get_styleclass(self, obj: _elkjs.ELKOutputChild) -> str | None:
def get_styleclass(self, uuid: str) -> str | None:
"""Return the style-class string from a given
[`_elkjs.ELKOutputChild`][capellambse_context_diagrams._elkjs.ELKOutputChild].
"""
styleclass: str | None
try:
melodyobj = self._diagram._model.by_uuid(obj["id"])
melodyobj = self._diagram._model.by_uuid(uuid)
styleclass = get_styleclass(melodyobj)
except KeyError:
styleclass = None
Expand Down
167 changes: 119 additions & 48 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,82 @@
# SPDX-License-Identifier: Apache-2.0

[build-system]
requires = [
"setuptools>=42",
"setuptools_scm[toml]>=3.4",
"wheel",
requires = ["setuptools>=61", "setuptools_scm[toml]>=3.4", "wheel"]
build-backend = "setuptools.build_meta"

[project]
dynamic = ["version"]

name = "capellambse-context-diagrams"
description = "Extension for python-capella-mbse that adds automatically generated context diagrams for arbitrary model elements."
readme = "README.md"
requires-python = ">=3.9, <3.11"
license = { file = "LICENSES/Apache-2.0.txt" }
authors = [
{ name = "DB Netz AG" },
]
keywords = ["capella", "mbse", "context", "diagram", "automatic diagrams"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Other/Nonlisted Topic",
"Topic :: Scientific/Engineering",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"capellambse",
"typing_extensions",
]

[project.urls]
Homepage = "https://github.com/DSD-DBS/capellambse-context-diagrams"
Documentation = "https://dsd-dbs.github.io/capellambse-context-diagrams"

[project.entry-points."capellambse.model_extensions"]
context_diagrams = "capellambse_context_diagrams:init"

[project.optional-dependencies]
docs = [
"mkdocs-material",
"mkdocstrings[python]>=0.18",
"pytkdocs[numpy-style]>=0.5.0",
"mkdocs-gen-files",
"mkdocs-literate-nav",
"mkdocs-section-index",
"mkdocs-autorefs",
]

test = [
"pytest",
"pytest-cov",
]

[tool.black]
line-length = 79
target-version = ['py38']
target-version = ["py39"]

[tool.isort]
ensure_newline_before_comments = true
force_grid_wrap = 0
include_trailing_comma = true
profile = "black"
line_length = 79
multi_line_output = 3
skip_glob = [
".*",
]
use_parentheses = true

[tool.mypy]
check_untyped_defs = true
no_implicit_optional = true
show_error_codes = true
warn_redundant_casts = true
warn_unreachable = true
python_version = "3.9"

[[tool.mypy.overrides]]
module = ["tests.*"]
allow_incomplete_defs = true
allow_untyped_defs = true

[tool.pydocstyle]
convention = "numpy"
Expand All @@ -39,67 +95,64 @@ add-ignore = [
"D213", # Multi-line docstring summary should start at the second line
]

[tool.pylint.format]
expected-line-ending-format = "LF"

[tool.pylint.master]
extension-pkg-allow-list = [
"lxml.etree",
]

[tool.pylint.messages_control]
disable = [
"arguments-differ", # handled by mypy
"assignment-from-no-return", # handled by mypy
"bad-indentation", # auto-formatting
"broad-except",
"consider-using-f-string",
"cyclic-import",
"global-statement",
"import-error", # handled by mypy
"import-outside-toplevel",
"inconsistent-quotes", # auto-formatting
"invalid-name",
"line-too-long", # auto-formatting
"missing-class-docstring",
"missing-final-newline", # auto-formatting
"missing-function-docstring",
"missing-kwoa", # handled by mypy
"missing-method-docstring",
"missing-module-docstring",
"mixed-line-endings", # auto-formatting
"multiple-imports", # auto-formatting
"multiple-statements", # auto-formatting
"no-else-break",
"no-else-continue",
"no-else-raise",
"no-else-return",
"no-member", # handled by mypy
"no-value-for-parameter", # handled by mypy
"protected-access",
"redefined-builtin",
"redundant-keyword-arg", # handled by mypy
"signature-differs", # handled by mypy
"syntax-error", # handled by mypy
"too-few-public-methods",
"too-many-ancestors",
"too-many-arguments",
"too-many-boolean-expressions",
"too-many-branches",
"too-many-function-args", # handled by mypy
"too-many-instance-attributes",
"too-many-lines",
"too-many-locals",
"too-many-public-methods",
"too-many-return-statements",
"too-many-statements",
"trailing-newlines", # auto-formatting
"trailing-whitespace", # auto-formatting
"unbalanced-tuple-unpacking", # handled by mypy
"undefined-variable", # handled by mypy
"unexpected-keyword-arg", # handled by mypy
"unexpected-line-ending-format", # auto-formatting
"ungrouped-imports", # auto-formatting
"wrong-import-order", # auto-formatting
"wrong-import-position", # auto-formatting

# Auto-formatting
"bad-indentation",
"inconsistent-quotes",
"line-too-long",
"missing-final-newline",
"mixed-line-endings",
"multiple-imports",
"multiple-statements",
"trailing-newlines",
"trailing-whitespace",
"unexpected-line-ending-format",
"ungrouped-imports",
"wrong-import-order",
"wrong-import-position",

# Handled by mypy
"arguments-differ",
"assignment-from-no-return",
"import-error",
"missing-kwoa",
"no-member",
"no-value-for-parameter",
"redundant-keyword-arg",
"signature-differs",
"syntax-error",
"too-many-function-args",
"unbalanced-tuple-unpacking",
"undefined-variable",
"unexpected-keyword-arg",
]
enable = [
"c-extension-no-member",
Expand All @@ -108,5 +161,23 @@ enable = [
"useless-suppression",
]

[tool.pytest.ini_options]
addopts = """
--strict-config
--strict-markers
"""
testpaths = ["tests"]
xfail_strict = true

[tool.setuptools]
platforms = ["any"]
zip-safe = false

[tool.setuptools.package-data]
"*" = ["py.typed", "*.js"]

[tool.setuptools.packages.find]
exclude = ["LICENSES"]

[tool.setuptools_scm]
# This section must exist for setuptools_scm to work
63 changes: 0 additions & 63 deletions setup.cfg

This file was deleted.

Loading

0 comments on commit 5e57ca8

Please sign in to comment.