Skip to content

chore: ruff lint fixes and formatting across all source files#239

Draft
korbonits wants to merge 2 commits intoshiyu-coder:masterfrom
korbonits:chore/ruff-format
Draft

chore: ruff lint fixes and formatting across all source files#239
korbonits wants to merge 2 commits intoshiyu-coder:masterfrom
korbonits:chore/ruff-format

Conversation

@korbonits
Copy link
Copy Markdown

Summary

Applies ruff check --fix and ruff format to all source files. No logic changes — behaviour is identical to master (and to #238, which this is based on).

Kept as a separate draft PR so reviewers can decide independently whether they want the formatting cleanup.

What changed

Rule Count Description
W293/W291 308 Trailing whitespace on blank/non-blank lines
I001 36 Unsorted / unformatted import blocks
F401 28 Unused imports (availability-check ones get # noqa: F401)
F541 8 f-strings without placeholders
UP009 8 Redundant # -*- coding: utf-8 -*- declarations
UP030 1 Explicit positional format index {0}{}
F841 3 Unused local variables
E401/E701 4 Multiple imports / statements on one line
ruff format 21 files Quote normalisation, line wrapping, indentation

Tooling config (in pyproject.toml from #238)

[tool.ruff]
line-length = 88
target-version = "py310"

[tool.ruff.lint]
select = ["E", "F", "W", "I", "UP"]
ignore = ["E501", "F403", "F405", "UP007"]

Test plan

All 65 unit tests from #238 continue to pass; the existing regression tests are unchanged.

uv sync --dev
uv run ruff check .   # clean
uv run pytest tests/  # 65 passed

🤖 Generated with Claude Code

Alex Korbonits and others added 2 commits April 11, 2026 22:32
- sample_from_logits: guard top_k/top_p None comparisons before
  checking `> 0` / `< 1.0` (TypeError when one arg is None)
- sample_from_logits: replace `top_k(probs, k=1)` with
  `torch.topk(probs, k=1)` — the parameter shadowed the function,
  making greedy decoding (sample_logits=False) uncallable
- BinarySphericalQuantizer.get_codebook_entry /
  get_group_codebook_entry: `h, w = int(...)` raises TypeError
  because a scalar int is not iterable; fix to `h = w = int(...)`
- FixedEmbedding: `w.require_grad = False` silently set a spurious
  attribute instead of disabling gradient tracking; fix to
  `w.requires_grad = False`

Add 65 offline unit tests (tests/test_sampling.py,
tests/test_bsq.py, tests/test_model_shapes.py) that cover all
three bugs as regression guards, plus shape/behaviour tests for
every major building block and both top-level models.

Add pyproject.toml with uv project definition, ruff (lint +
format), ty (type checker), and pytest config. Add uv.lock for
reproducible installs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove unused imports and variables (F401, F841)
- Sort and reformat import blocks (I001)
- Strip trailing whitespace from blank lines (W293, W291)
- Remove redundant UTF-8 coding declarations (UP009)
- Convert f-strings without placeholders to plain strings (F541)
- Replace explicit positional format indices with implicit ones (UP030)
- Expand single-line compound statements (E701)
- Reformat code style with ruff format (quotes, line length, indentation)
- Add # noqa annotations for intentional availability-check imports
  and a ruff false-positive (F823 on a properly imported os)

No behaviour changes; all 65 unit tests continue to pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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