Skip to content

Conversation

@Jython1415
Copy link
Owner

Summary

Implements comprehensive code quality tooling using modern, fast linters to address issue #112.

Changes

Python Linting:

  • Added Ruff for linting and formatting (single tool replacing Black + Flake8 + isort)
  • Configured in pyproject.toml with:
    • Line length: 100 characters
    • Enabled rulesets: pycodestyle, pyflakes, isort, pep8-naming, pyupgrade, flake8-bugbear, flake8-comprehensions, flake8-simplify, flake8-return
    • Auto-fix enabled for safe violations

YAML Linting:

  • Added yamllint for formula YAMLs and workflow files
  • Configured in .yamllint with:
    • Line length warnings at 120 characters (accommodates long formulas)
    • 2-space indentation (GitHub Actions standard)
    • Support for truthy values in GH Actions (on/off, yes/no)

CI Integration:

  • Updated .github/workflows/test.yml with 3 new steps:
    1. Lint Python code with Ruff
    2. Check Python formatting with Ruff
    3. Lint YAML files with yamllint
  • Linting runs before tests to fail fast on style issues

Code Quality Improvements:

  • Fixed all existing linting violations:
    • Removed unused imports and variables
    • Fixed import ordering and formatting
    • Simplified nested if statements
    • Added proper exception chaining (raise...from)
    • Applied consistent code formatting
    • Removed trailing whitespace from YAML files

Testing

  • ✅ All 156 existing tests pass
  • ✅ Formula linter passes (33/33 files)
  • ✅ README generation succeeds
  • ✅ Ruff linting passes (0 violations)
  • ✅ Ruff formatting check passes
  • ✅ yamllint passes (0 errors, only warnings for long lines which are acceptable)

Benefits

  • Fast: Ruff is 10-100x faster than traditional Python linters
  • Simple: Single tool instead of 3-5 separate tools
  • Modern: Uses current Python ecosystem standards
  • Maintainable: Centralized configuration in pyproject.toml
  • Automated: CI fails fast on style violations

Closes #112

Implements comprehensive code quality tooling using modern, fast linters:

**Python Linting:**
- Added Ruff for linting and formatting (replaces Black + Flake8 + isort)
- Configured in pyproject.toml with sensible defaults:
  - Line length: 100 characters
  - Enabled rulesets: pycodestyle, pyflakes, isort, pep8-naming, pyupgrade,
    flake8-bugbear, flake8-comprehensions, flake8-simplify, flake8-return
  - Auto-fix enabled for safe violations

**YAML Linting:**
- Added yamllint for formula YAMLs and workflow files
- Configured in .yamllint with project-specific rules:
  - Line length warnings at 120 characters (allows long formulas)
  - 2-space indentation (GitHub Actions standard)
  - Supports truthy values for GH Actions (on/off, yes/no)

**CI Integration:**
- Updated .github/workflows/test.yml with 3 new steps:
  1. Lint Python code with Ruff
  2. Check Python formatting with Ruff
  3. Lint YAML files with yamllint
- Linting runs before tests to fail fast on style issues

**Code Fixes:**
- Fixed all linting violations in existing code:
  - Removed unused imports and variables
  - Fixed import ordering and formatting
  - Simplified nested if statements
  - Added proper exception chaining (raise...from)
  - Applied consistent code formatting
  - Removed trailing whitespace from YAML files

**Dependencies:**
- Added ruff>=0.8.0 and yamllint>=1.35.0 to dev dependencies
- Updated uv.lock with new dependencies

All existing tests pass (156/156). Ready for CI validation.
@Jython1415 Jython1415 force-pushed the claude/setup-linting-ci-Ue7bP branch from b82d57b to 9ea7c8c Compare January 19, 2026 21:02
Update test expectations to reflect the addition of ValidFormulaSyntaxRule
during rebase:

- test_linter_has_expected_rules: Now expects 3 rules (added
  valid-formula-syntax rule)
- test_lint_file_with_self_executing_lambda_warning: Self-executing LAMBDAs
  now produce 1 error from ValidFormulaSyntaxRule (invalid syntax) + 1
  warning from NoTopLevelLambdaRule (unnecessary pattern)
- test_lint_all_counts_warnings: Updated to expect 1 error + 1 warning for
  the same reason

This fixes the test failures caused by the rebase conflict resolution that
added ValidFormulaSyntaxRule to the linter while some tests still expected
the old behavior.
Resolved merge conflict in tests/test_linter.py by:
- Importing both RequireParameterExamplesRule and ValidFormulaSyntaxRule
- Updating test assertions to expect 4 linting rules
- Using single quotes for consistency
@Jython1415 Jython1415 merged commit b2e5233 into main Jan 19, 2026
2 checks passed
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.

Add Python and YAML linters and code formatting to the CI/CD pipeline

3 participants