Add ruff linting and apply code style fixes#16
Merged
Conversation
Configure ruff (lint + format) in pyproject.toml with a 120-char line length matching the existing style, and enable a curated ruleset (E, F, W, I, UP, B, SIM, C4, RUF). Add a `dev` optional-dependency group and a CI workflow that runs `ruff check` and `ruff format --check` on every push and pull request. Bring the codebase fully into compliance: - apply ruff formatting across all modules - raise from None in date/init error paths (B904) - use contextlib.suppress for the size-tally OSError (SIM105) - drop the redundant utf-8 encode argument in ics (UP012) - treat the immutable KdfParams dataclass as a safe default (B008) Closes #12 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ARYv6iMTZ7UiZnbUL1LnJC
Add focused rule groups that flag the patterns most often left behind by AI-generated code, then bring the codebase into compliance: - ERA: commented-out / dead code - BLE: blind `except:` that swallows everything - RET: redundant else/return after a return - PERF: obvious performance anti-patterns - PIE: unnecessary pass / redundant constructs - TRY: exception-handling anti-patterns (TRY003 ignored as too noisy for a small CLI's raise-site messages) - PLW: pylint warnings, e.g. clobbered loop variables - PLR2004: unexplained magic numbers in comparisons Most groups were already clean, so they act as guardrails. Fixed the few real smells they surfaced: - name the byte-unit step constant in status size formatting - name the RFC 5545 fold limit and utf-8 continuation-byte masks in ics - stop reusing the loop variable while normalizing paths in _pack Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ARYv6iMTZ7UiZnbUL1LnJC
main added `info --json` after this branch was cut; its print(json.dumps(...)) block wasn't ruff-formatted, so the lint workflow failed on the PR's merge commit even though the branch passed on its own. Reformat it to satisfy `ruff format --check`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ARYv6iMTZ7UiZnbUL1LnJC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces ruff as the project's linter and applies comprehensive code style fixes across the codebase to comply with the new linting rules.
Key Changes
Linting Infrastructure:
pyproject.toml.github/workflows/lint.yml) to enforce linting on all pushes and PRsCode Style Fixes Applied:
_FOLD_LIMIT,_UNIT_STEP,_UTF8_CONT_MASK).encode("utf-8")to.encode()where appropriate2 ** 15→2**15)contextlib.suppress()for cleaner codepath→normto avoid shadowing)Notable Implementation Details:
noqacomment inmagicicapsula/commands/config.pyto suppress a false positive (config module iteration)KdfParamsas an immutable dataclass safe for use as a default argumentTRY003for CLI error messages)https://claude.ai/code/session_01ARYv6iMTZ7UiZnbUL1LnJC