Skip to content

Commit 34df9fa

Browse files
committed
fix: resolve mypy type errors and ruff linting issues
- Add FileSystemLoader type check for loader.searchpath access - Add explicit type conversion for generated_by version - Fix import order in sync.py - All mypy and ruff checks passing
1 parent 62a1f93 commit 34df9fa

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/metaspec/cli/sync.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,12 @@ def sync_command(
114114

115115
# Step 6: Get new commands from installed MetaSpec
116116
try:
117+
from jinja2 import FileSystemLoader
118+
117119
from metaspec.generator import Generator
118120
gen = Generator()
121+
if not isinstance(gen.env.loader, FileSystemLoader):
122+
raise RuntimeError("Unexpected loader type")
119123
template_dir = Path(gen.env.loader.searchpath[0]) / "meta"
120124
except Exception as e:
121125
console.print(
@@ -175,7 +179,8 @@ def _read_generated_version() -> str | None:
175179
try:
176180
with open("pyproject.toml", "rb") as f:
177181
data = tomllib.load(f)
178-
return data.get("tool", {}).get("metaspec", {}).get("generated_by")
182+
version = data.get("tool", {}).get("metaspec", {}).get("generated_by")
183+
return str(version) if version is not None else None
179184
except Exception:
180185
return None
181186

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)