Skip to content

Add Ruff linting, pre-commit hooks, and CI#58

Open
korbonits wants to merge 1 commit intozjunlp:mainfrom
korbonits:add-ruff-ci
Open

Add Ruff linting, pre-commit hooks, and CI#58
korbonits wants to merge 1 commit intozjunlp:mainfrom
korbonits:add-ruff-ci

Conversation

@korbonits
Copy link
Copy Markdown

Summary

Adds Ruff linting + CI enforcement to catch style and correctness issues on every PR.

Changes:

  • pyproject.toml: add [tool.ruff] config (E/F/I rules, line-length 120, notebooks excluded)
  • .pre-commit-config.yaml: ruff + ruff-format hooks
  • .github/workflows/lint.yml: lint job via uv on push/PR
  • src/lightmem/memory/graph.py: fix stub class body (added pass — the file was class GraphMem:\n which is a syntax error)

Auto-fixed 217 import-sort and style violations.

Three items flagged for maintainer attention:

  • Duplicate dictionary keys (F601)src/lightmem/memory/lightmem.py:166-167 declares "embedding_calls" and "embedding_total_tokens" twice in the token stats dict initializer; the second assignment silently overwrites the first. The stats dict likely has the right keys at the end, but the first four entries (lines 160-161) are dead.
  • Potential NameError (F821)experiments/locomo/llm_judge.py:60 references client before it is assigned in the enclosing scope.
  • Stub classgraph.py was an empty class body (class GraphMem: with no pass), causing a Python IndentationError on import. Fixed.

Both F601 and F821 are suppressed in the config so CI passes, but flagging for maintainer attention.

Ruff version: v0.12.2

- Add [tool.ruff] config to pyproject.toml (E/F/I rules, line-length 120)
- Add .pre-commit-config.yaml with ruff + ruff-format hooks
- Add .github/workflows/lint.yml CI job via uv
- Fix src/lightmem/memory/graph.py: stub class body was missing (added pass)

Auto-fixed 217 import-sort, style, and formatting violations. Remaining notes:
- F601: duplicate dictionary keys in lightmem.py:166-167
  ('embedding_calls' and 'embedding_total_tokens' each appear twice in the
  token stats dict — the second assignment silently overwrites the first)
- F821: undefined name 'client' in experiments/locomo/llm_judge.py:60
  (referenced before assignment; potential NameError at runtime)
Both are suppressed in the config so CI passes, but flagging for maintainer
attention.
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