Skip to content

Fix pre-existing ruff and mypy strict-mode violations#28

Closed
severity1 wants to merge 1 commit intomainfrom
chore/fix-lint-and-type-errors
Closed

Fix pre-existing ruff and mypy strict-mode violations#28
severity1 wants to merge 1 commit intomainfrom
chore/fix-lint-and-type-errors

Conversation

@severity1
Copy link
Copy Markdown
Owner

Summary

Cleans up 12 pre-existing lint/type errors on main that were blocking uv run ruff check . and uv run mypy scripts/ from returning clean:

  • ruff (1): E402 in tests/test_trigger.py - import importlib sat below a sys.path.insert call. importlib is stdlib and has no path dependency, so it moves cleanly to the top-of-file imports block.
  • mypy strict (11): Missing generic parameters on dict, no-any-return on json.load, untyped main() functions, and an overly loose return type on handle_git_commit.

These existed on main before any recent PRs - verified via git stash + baseline run. No runtime behaviour changes in this PR.

Why bother

Baseline noise in lint/type output makes it hard to tell real issues from accepted ones in future PRs. With the baseline clean, any new violation stands out immediately instead of being hidden in a pile of 12 pre-existing errors. This is groundwork for eventually adding these checks to a pre-commit hook or GitHub Action.

Changes

File Change
scripts/trigger.py Import typing.Any; dict -> dict[str, Any] on load_config, handle_stop, handle_pre_tool_use; annotate main() -> None; typed local for stdin parse
scripts/post-tool-use.py Same typing.Any + dict[str, Any] treatment on load_config and main(); narrow handle_git_commit return to dict[str, str] | None matching the real {"hash", "message"} shape
tests/test_trigger.py Move import importlib to top-level imports

Verification

$ uv run ruff check .
All checks passed!

$ uv run ruff format --check .
7 files already formatted

$ uv run mypy scripts/
Success: no issues found in 2 source files

$ uv run pytest tests/
============================= 123 passed in 0.90s ==============================

Test plan

  • uv run ruff check . clean
  • uv run ruff format --check . clean
  • uv run mypy scripts/ clean
  • uv run pytest tests/ 123/123 passing
  • No runtime behaviour changes (only type annotations and import order)

Relationship to #27

Independent cleanup PR. #27 fixes bugs; this one fixes the baseline. Merging either first works; if #27 merges first, a trivial rebase may be needed here.

Clean up lint/type errors that existed on main but had not been
addressed. These were blocking `uv run ruff check .` and
`uv run mypy scripts/` from returning clean, making it hard to tell
real issues from baseline noise in future PRs.

- trigger.py, post-tool-use.py: Import `typing.Any`, parameterise
  `dict` annotations as `dict[str, Any]` on load_config, handle_stop,
  handle_pre_tool_use, and stdin parsing locals.
- trigger.py, post-tool-use.py: Annotate `main() -> None` so the
  top-level `if __name__ == "__main__": main()` call is no longer a
  no-any-return violation.
- post-tool-use.py: Narrow `handle_git_commit`'s return type from
  `dict | None` to `dict[str, str] | None` to match the actual
  `{"hash": ..., "message": ...}` shape.
- test_trigger.py: Move `import importlib` to the top-level imports
  block so it no longer trips E402 after the `sys.path.insert` call.

Pure cleanup - no runtime behaviour changes. All 123 tests still pass.
severity1 added a commit that referenced this pull request Apr 11, 2026
Combines #17 fix (skip hooks on uninitialized projects) with #28's
type annotation cleanup (dict[str, Any], typed main(), narrowed
handle_git_commit return type). Both sets of changes now live in
PR #27's branch. PR #28 can be closed.
@severity1
Copy link
Copy Markdown
Owner Author

Absorbed into PR #27 (fix/subagent-stop-cleanup-and-windows-paths). All type annotation changes from this branch have been merged there directly. 132 tests passing, ruff and mypy clean.

@severity1 severity1 closed this Apr 11, 2026
severity1 added a commit that referenced this pull request Apr 11, 2026
…ns (#28)

- Add ^ anchor to SubagentStop matcher regex to prevent partial matches
- Instruct Stop/PreToolUse hooks to set subagent_type='auto-memory:memory-updater'
  so Claude Code can match the SubagentStop hook against the spawned agent
- Bump to v0.8.4
severity1 added a commit that referenced this pull request Apr 11, 2026
…ns (#28) (#29)

- Add ^ anchor to SubagentStop matcher regex to prevent partial matches
- Instruct Stop/PreToolUse hooks to set subagent_type='auto-memory:memory-updater'
  so Claude Code can match the SubagentStop hook against the spawned agent
- Bump to v0.8.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant