Skip to content

Commit 9a6b023

Browse files
committed
Automatic ruff lint fixes, plus some type additions and docs.
1 parent dcae577 commit 9a6b023

13 files changed

+225
-175
lines changed

tests/test_compiler/test_duckdb_compiler.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""
2-
Tests compilation of a specification to python
2+
Tests compilation of a specification to python.
33
"""
44

5+
import duckdb
56
import pytest
67
from linkml_runtime import SchemaView
78
from linkml_runtime.dumpers import yaml_dumper
@@ -12,14 +13,16 @@
1213

1314

1415
@pytest.fixture
15-
def session():
16+
def session() -> Session:
17+
"""LinkML transformer session with schema and spec set."""
1618
session = Session()
1719
session.set_source_schema(SCHEMA1)
1820
session.set_transformer_specification(SPECIFICATION)
1921
return session
2022

2123

22-
def test_compile(session):
24+
def test_compile(session: Session) -> None:
25+
"""Test the DuckDb compiler."""
2326
compiler = SQLCompiler()
2427
assert session.transformer_specification is not None
2528
compiled = compiler.compile(session.transformer_specification)
@@ -37,8 +40,6 @@ def test_compile(session):
3740
print("Target DDL:")
3841
print(target_ddl)
3942

40-
import duckdb
41-
4243
conn = duckdb.connect(":memory:")
4344
conn.execute(target_ddl)
4445
conn.execute(compiled.serialization)

tests/test_compiler/test_graphviz_compiler.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Tests compilation of a specification to graphviz
2+
Tests compilation of a specification to graphviz.
33
"""
44

55
import pytest
@@ -11,16 +11,17 @@
1111

1212

1313
@pytest.fixture
14-
def compiler():
14+
def compiler() -> GraphvizCompiler:
15+
"""Instantiate a GraphvizCompiler."""
1516
return GraphvizCompiler(
1617
source_schemaview=SchemaView(SCHEMA1),
1718
)
1819

1920

20-
def test_compile(compiler):
21+
def test_compile(compiler: GraphvizCompiler) -> None:
22+
"""Basic test of the graphviz compiler functionality."""
2123
spec = load_specification(SPECIFICATION)
2224
compiled = compiler.compile(spec)
23-
# print(compiled.serialization)
2425
assert (
2526
"sourceMapping:id -> targetDenormMapping:subject_id [style=dashed]"
2627
in compiled.serialization

tests/test_compiler/test_markdown_compiler.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Tests compilation of a specification to markdown
2+
Tests compilation of a specification to markdown.
33
"""
44

55
import pytest
@@ -11,13 +11,15 @@
1111

1212

1313
@pytest.fixture
14-
def compiler():
14+
def compiler() -> MarkdownCompiler:
15+
"""Instantiate a MarkdownCompiler."""
1516
return MarkdownCompiler(
1617
source_schemaview=SchemaView(SCHEMA1),
1718
)
1819

1920

20-
def test_compile(compiler):
21+
def test_compile(compiler: MarkdownCompiler) -> None:
22+
"""Basic test of Markdown Compiler functioning."""
2123
assert compiler.template_name is not None
2224
spec = load_specification(SPECIFICATION)
2325
markdown = compiler.compile(spec).serialization

tests/test_compiler/test_python_compiler.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Tests compilation of a specification to python
2+
Tests compilation of a specification to python.
33
"""
44

55
import pytest
@@ -13,15 +13,17 @@
1313

1414

1515
@pytest.fixture
16-
def compiler():
16+
def compiler() -> PythonCompiler:
17+
"""Instantiate a Python Compiler."""
1718
return PythonCompiler(
1819
source_schemaview=SchemaView(SCHEMA1),
1920
source_python_module="tests.input.examples.personinfo_basic.model.personinfo_model",
2021
target_python_module="tests.input.examples.personinfo_basic.model.agent_model",
2122
)
2223

2324

24-
def test_compile(compiler):
25+
def test_compile(compiler: PythonCompiler) -> None:
26+
"""Basic test of Python Compiler functionality."""
2527
spec = load_specification(SPECIFICATION)
2628
pycode = compiler.compile(spec)
2729
# TODO: include imports so that code compiles

0 commit comments

Comments
 (0)