Skip to content

Commit 91bc952

Browse files
author
linkmluser
committed
Adding documentation
1 parent db0fc5e commit 91bc952

File tree

5 files changed

+103
-7
lines changed

5 files changed

+103
-7
lines changed

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ dependencies = [
1313
"typer>=0.9.0",
1414
]
1515

16+
[dependency-groups]
17+
dev = [
18+
"pytest>=8.0.0",
19+
"mypy>=1.0.0",
20+
"ruff>=0.1.0",
21+
]
22+
1623
[project.scripts]
1724
linkml-browser = "linkml_browser:main"
1825

src/linkml_browser/core.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import json
44
import shutil
55
from pathlib import Path
6-
from typing import Any, Dict, List, Optional
6+
from typing import Any, Dict, List, Optional, Set
77

88

99
class BrowserGenerator:
@@ -35,12 +35,12 @@ def infer_schema(self,
3535
raise ValueError("Cannot infer schema from empty data")
3636

3737
# Get all unique keys from all items
38-
all_keys = set()
38+
all_keys: Set[str] = set()
3939
for item in self.data:
4040
all_keys.update(item.keys())
4141

4242
# Analyze field types from first few items
43-
field_info = {}
43+
field_info: Dict[str, Dict[str, Any]] = {}
4444
sample_size = min(100, len(self.data))
4545

4646
for key in all_keys:
@@ -70,7 +70,7 @@ def infer_schema(self,
7070
field_info[key]['unique_values'].add(value)
7171

7272
# Build schema
73-
schema = {
73+
schema: Dict[str, Any] = {
7474
"title": title,
7575
"description": description,
7676
"searchPlaceholder": "Search...",
@@ -103,7 +103,7 @@ def infer_schema(self,
103103
int_values = [int(v) for v in info['unique_values'] if v]
104104
if len(int_values) == len(info['unique_values']):
105105
facet_type = "integer"
106-
except:
106+
except ValueError:
107107
pass
108108

109109
schema["facets"].append({

src/linkml_browser/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def init_schema(
106106
save_schema(schema, output_file)
107107

108108
typer.echo(f"\n✅ Schema written to: {output_file}")
109-
typer.echo(f"Edit this file to customize facets, search fields, and display options.")
109+
typer.echo("Edit this file to customize facets, search fields, and display options.")
110110
typer.echo(f"Then run: linkml-browser deploy {data_file} output/ --schema {output_file}")
111111

112112

tests/test_browser_generator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Unit tests for LinkML Browser generator functionality."""
22

3-
import json
43
import tempfile
54
from pathlib import Path
65

uv.lock

Lines changed: 90 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)