CMLDEV-1069 Enable ruff linting in PCL, replace flake8/isort/black#217
Open
marpauli-cisco wants to merge 3 commits intodevfrom
Open
CMLDEV-1069 Enable ruff linting in PCL, replace flake8/isort/black#217marpauli-cisco wants to merge 3 commits intodevfrom
marpauli-cisco wants to merge 3 commits intodevfrom
Conversation
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.
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:
pyproject.tomlreusing the monorepo core rule set with PCL-appropriate overridesChanges:
Config (
pyproject.toml):[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 settingsflake8dev dependency withruffSource (
virl2_client/):ClassVarannotations to mutable class-level dicts (_URL_TEMPLATES,_ERROR_PREFIX) across 15 model filesTests (
tests/):withstatements (SIM117) across 12 test filespytest.raises(match=...)patterns (RUF043)pytest.raises(Exception)(B017), function call in default argument (B008), if/else to ternary (SIM108)CI & tooling:
ruff check --no-fix+ruff format --checkin GitHub Actions.pre-commit-config.yamlruffhook ID toruff-checkpoetry.lockandtests/requirements.txtTesting:
ruff check virl2_client/ tests/ conftest.py— all checks passedruff format --check virl2_client/ tests/ conftest.py— all files formattedpytest -n auto— all 1543 tests passing