From 079dc406a407dca310d151769b890c9f03d02960 Mon Sep 17 00:00:00 2001 From: Markus Binsteiner Date: Fri, 17 Nov 2023 10:31:04 +0100 Subject: [PATCH] chore: minor mypy issues --- pyproject.toml | 5 ++++- src/kiara_plugin/jupyter/entrypoints.py | 1 - src/kiara_plugin/jupyter/renderers/pipeline.py | 9 +++++---- src/kiara_plugin/jupyter/utils/__init__.py | 7 ++++--- src/kiara_plugin/jupyter/utils/graphs.py | 8 +------- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fa7822c..7d3dd32 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -255,5 +255,8 @@ plugins = [ # mypy per-module options: [[tool.mypy.overrides]] -module = ["placholder.dummy.*"] +module = [ + "ipydagred3.*", + "jupytext.*" +] ignore_missing_imports = true diff --git a/src/kiara_plugin/jupyter/entrypoints.py b/src/kiara_plugin/jupyter/entrypoints.py index 8c3ab83..df9131f 100644 --- a/src/kiara_plugin/jupyter/entrypoints.py +++ b/src/kiara_plugin/jupyter/entrypoints.py @@ -13,7 +13,6 @@ find_kiara_renderers_under, find_pipeline_base_path_for_module, ) - from kiara_plugin.jupyter import KIARA_METADATA find_modules: KiaraEntryPointItem = ( diff --git a/src/kiara_plugin/jupyter/renderers/pipeline.py b/src/kiara_plugin/jupyter/renderers/pipeline.py index 02c32b9..7717d4e 100644 --- a/src/kiara_plugin/jupyter/renderers/pipeline.py +++ b/src/kiara_plugin/jupyter/renderers/pipeline.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- -from typing import Any, Iterable, Mapping, Union +from typing import Any, Iterable, Mapping, MutableMapping, Union from jinja2 import Template + from kiara.models.module.pipeline.pipeline import Pipeline from kiara.renderers import RenderInputsSchema, SourceTransformer from kiara.renderers.included_renderers.pipeline import PipelineTransformer @@ -38,7 +39,7 @@ def assemble_render_inputs( self, instance: Any, render_config: RenderInputsSchema ) -> Mapping[str, Any]: - inputs = render_config.dict() + inputs: MutableMapping[str, Any] = render_config.model_dump() inputs["pipeline"] = instance return inputs @@ -49,14 +50,14 @@ def _post_process(self, rendered: str) -> str: import jupytext notebook = jupytext.reads(rendered, fmt="py:percent") - converted = jupytext.writes(notebook, fmt="notebook") + converted: str = jupytext.writes(notebook, fmt="notebook") return converted else: try: import black from black import Mode # type: ignore - cleaned = black.format_str(rendered, mode=Mode()) + cleaned: str = black.format_str(rendered, mode=Mode()) return cleaned except Exception as e: diff --git a/src/kiara_plugin/jupyter/utils/__init__.py b/src/kiara_plugin/jupyter/utils/__init__.py index a96ec73..633cce6 100644 --- a/src/kiara_plugin/jupyter/utils/__init__.py +++ b/src/kiara_plugin/jupyter/utils/__init__.py @@ -46,12 +46,13 @@ def ensure_kiara_plugins(*plugins, update: bool = False): if not update: plugin_packages: List[str] = [] pkgs = [p.replace("_", "-") for p in installed_packages.keys()] - for package_name in plugins: - if package_name.startswith("git:"): - package_name = package_name.replace("git:", "") + for _package_name in plugins: + if _package_name.startswith("git:"): + package_name = _package_name.replace("git:", "") git = True else: git = False + package_name = _package_name package_name = package_name.replace("_", "-") if not package_name.startswith("kiara-plugin."): package_name = f"kiara-plugin.{package_name}" diff --git a/src/kiara_plugin/jupyter/utils/graphs.py b/src/kiara_plugin/jupyter/utils/graphs.py index fad2d39..f21a817 100644 --- a/src/kiara_plugin/jupyter/utils/graphs.py +++ b/src/kiara_plugin/jupyter/utils/graphs.py @@ -14,7 +14,7 @@ def graph_widget( pipeline = pipeline.structure # type: ignore try: - import ipydagred3 as ipydagred3 + import ipydagred3 except Exception: raise Exception( "ipydagred3 not available, please install it manually into the current virtualenv" @@ -37,13 +37,7 @@ def graph_widget( for edge in graph.edges: e = str(edge[0]) - if e not in nodes_set: - print("MISSING") - print(e) e2 = str(edge[1]) - if e2 not in nodes_set: - print("MISSING 2") - print(e2) g.setEdge(e, e2) widget = ipydagred3.DagreD3Widget(graph=g)