Skip to content

CMLDEV-1069 Enable ruff linting in PCL, replace flake8/isort/black#217

Open
marpauli-cisco wants to merge 3 commits intodevfrom
CMLDEV-1069-ruff-in-pcl
Open

CMLDEV-1069 Enable ruff linting in PCL, replace flake8/isort/black#217
marpauli-cisco wants to merge 3 commits intodevfrom
CMLDEV-1069-ruff-in-pcl

Conversation

@marpauli-cisco
Copy link
Copy Markdown
Collaborator

Summary:

  • Add comprehensive ruff configuration to pyproject.toml reusing the monorepo core rule set with PCL-appropriate overrides
  • Fix all 52 ruff violations across source and test files
  • Replace flake8/isort/black with ruff in CI and pre-commit hooks

Changes:

Config (pyproject.toml):

  • Add [tool.ruff] with rule selection (E, W, F, I, PL, S, B, UP, N, SIM, C4, A, RUF, G, T20), ignore set, per-file-ignores for tests and API-driven constructors, isort and format settings
  • Replace flake8 dev dependency with ruff

Source (virl2_client/):

  • Add ClassVar annotations to mutable class-level dicts (_URL_TEMPLATES, _ERROR_PREFIX) across 15 model files

Tests (tests/):

  • Collapse nested with statements (SIM117) across 12 test files
  • Escape regex metacharacters in pytest.raises(match=...) patterns (RUF043)
  • Fix collapsible if statements (SIM102), blind pytest.raises(Exception) (B017), function call in default argument (B008), if/else to ternary (SIM108)
  • Apply ruff-format fixes to 2 test files

CI & tooling:

  • Replace flake8 lint step with ruff check --no-fix + ruff format --check in GitHub Actions
  • Remove isort and black hooks from .pre-commit-config.yaml
  • Rename legacy ruff hook ID to ruff-check
  • Regenerate poetry.lock and tests/requirements.txt

Testing:

  • ruff check virl2_client/ tests/ conftest.py — all checks passed
  • ruff format --check virl2_client/ tests/ conftest.py — all files formatted
  • pytest -n auto — all 1543 tests passing

Configure ruff with the monorepo core rule set (E, W, F, I, PL, S, B,
UP, N, SIM, C4, A, RUF, G, T20) and PCL-appropriate overrides.
Add per-file-ignores for tests and API-driven constructors.
Add ClassVar annotations to mutable class-level dicts (_URL_TEMPLATES
etc.) across 15 model files. In tests, collapse nested with statements,
escape regex metacharacters in pytest match patterns, replace if/else
with ternary, and fix blind pytest.raises(Exception).
Remove isort and black hooks from pre-commit config; rename legacy
'ruff' hook ID to 'ruff-check'. Replace flake8 CI step with
ruff check + ruff format --check. Swap flake8 dev dependency for
ruff and regenerate lock/requirements. Apply ruff-format fixes to
two test files.
@tmikuska tmikuska changed the base branch from main to dev April 26, 2026 07:36
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