CMLDEV-1069 Enable ruff linting in PCL, replace flake8/isort/black#217
Merged
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.
Apply the same import cleanups across all tests as in the autostart/ backward_compat changes: - Switch `from helpers` to `from tests.helpers` so the local module is imported through its package path (groups it with first-party imports after ruff sorting). - Consolidate `from virl2_client.models.<sub> import X` into `from virl2_client.models import X` where X is re-exported by `models/__init__.py`. Mixed imports (where some symbols aren't re-exported) are left untouched. - Drop redundant inline `import` statements in test_client_library_runtime.py that duplicate module-level imports. Add two tests in test_event_listening.py to close the previously-missed branches in event_listening.py: - test_ssl_verify_path_missing_raises: covers the FileNotFoundError branch in _init_ws_connection_data when ssl_verify points at a non-existent file (line 95). - test_parse_cancels_pending_close_wait_on_error: covers the finally branch that cancels close_wait when _parse() exits via an exception before _ws_close_event is set (lines 193-195). event_listening.py is now at 100% line coverage, and the whole virl2_client package reports 100% / 1547 tests pass.
tmikuska
approved these changes
May 11, 2026
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