Skip to content

Commit

Permalink
chore: minor mypy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
makkus committed Nov 17, 2023
1 parent c86db37 commit 079dc40
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -255,5 +255,8 @@ plugins = [

# mypy per-module options:
[[tool.mypy.overrides]]
module = ["placholder.dummy.*"]
module = [
"ipydagred3.*",
"jupytext.*"
]
ignore_missing_imports = true
1 change: 0 additions & 1 deletion src/kiara_plugin/jupyter/entrypoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
find_kiara_renderers_under,
find_pipeline_base_path_for_module,
)

from kiara_plugin.jupyter import KIARA_METADATA

find_modules: KiaraEntryPointItem = (
Expand Down
9 changes: 5 additions & 4 deletions src/kiara_plugin/jupyter/renderers/pipeline.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions src/kiara_plugin/jupyter/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
8 changes: 1 addition & 7 deletions src/kiara_plugin/jupyter/utils/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down

0 comments on commit 079dc40

Please sign in to comment.