Skip to content

[ruff] Enable additional rules: RSE, FLY, ICN, PIE, FURB - #4277

Merged
AlexanderDokuchaev merged 7 commits into
openvinotoolkit:developfrom
AlexanderDokuchaev:ad/ruff_new_rules
Oct 22, 2026
Merged

AlexanderDokuchaev merged 7 commits into
openvinotoolkit:developfrom
AlexanderDokuchaev:ad/ruff_new_rules

Conversation

@AlexanderDokuchaev

@AlexanderDokuchaev AlexanderDokuchaev commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Changes

  • Enabled new ruff rule sets in pyproject.toml:
    • RSE (flake8-raise)
    • FLY (flynt)
    • ICN (flake8-import-conventions)
    • PIE (flake8-pie)
    • FURB (refurb), with FURB113, FURB118, FURB140, FURB187 ignored
  • Fixed violations reported by the new rules across src/, tests/, examples/ and tools/.
  • Removed the unused commands_are_equal helper from tests/torch/helpers.py.
  • Sorted select/ignore lists in the ruff config alphabetically.

Reason for changes

Improve code quality and consistency through stricter linting.

Related tickets

N/A

Tests

Test examples - success

@AlexanderDokuchaev
AlexanderDokuchaev requested a review from a team as a code owner October 21, 2026 13:11
Copilot AI balanced review requested due to automatic review settings October 21, 2026 13:11
@github-actions github-actions Bot added NNCF PT Pull requests that updates NNCF PyTorch NNCF Common Pull request that updates NNCF Common NNCF OpenVINO Pull requests that updates NNCF OpenVINO NNCF ONNX Pull requests that updates NNCF ONNX labels Oct 21, 2026
@AlexanderDokuchaev AlexanderDokuchaev changed the title Enable additional ruff rules: RSE, FLY, ICN, PIE, FURB [ruff] Enable additional rules: RSE, FLY, ICN, PIE, FURB Oct 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The mechanical lint cleanups preserve behavior, with no blocking issues identified in static review; tests were not run.

No open issues 🎉

What changed in this PR

Strengthens NNCF’s linting standards and applies corresponding cleanups across source code, tests, examples, and tools.

Changes:

  • Enables RSE, FLY, ICN, PIE, and FURB rules with selected exclusions.
  • Simplifies equivalent expressions, collection operations, and file handling.
  • Removes the unused commands_are_equal test helper.
File Description
tools/​other/​extract_ov_subgraph.py Uses pathlib for XML output.
tools/​memory_monitor/​memory_monitor.py Writes measurements with writelines.
tools/​data_visualizer/​visualize_compression_results.py Uses pathlib for Markdown output.
tests/​torch/​quantization/​test_solver_quantization_traits.py Uses bulk set updates.
tests/​torch/​quantization/​test_functions.py Simplifies range expressions.
tests/​torch/​quantization/​extensions/​isolated_cases.py Simplifies singleton comparison.
tests/​torch/​helpers.py Removes unused helper and imports.
tests/​torch/​fx/​test_smooth_quant.py Combines prefix checks.
tests/​torch/​function_hook/​quantization/​test_smooth_quant.py Combines prefix checks.
tests/​torch/​function_hook/​quantization/​test_calculation_quantizer_params.py Simplifies range expressions.
tests/​openvino/​tools/​config.py Simplifies defaults and extension comparison.
tests/​openvino/​native/​quantization/​test_graphs.py Uses an explicit keyword argument.
tests/​onnx/​test_e2e_ptq.py Uses pathlib for HTML output.
tests/​docs/​test_version.py Uses explicit regex flag names.
tests/​docs/​test_md_pypiplishing.py Uses explicit regex flag names.
tests/​cross_fw/​test_templates/​test_statistics_caching.py Removes redundant pass statements.
tests/​cross_fw/​examples/​test_examples.py Uses pathlib to read requirements.
tests/​common/​test_telemetry.py Simplifies exception raising.
tests/​common/​test_reducers_and_aggregators.py Simplifies a range expression.
tests/​common/​quantization/​test_quantizer_propagation_graph.py Simplifies a range expression.
tests/​common/​quantization/​test_passes.py Removes a redundant pass.
tests/​common/​quantization/​mock_graphs.py Simplifies a range expression.
tests/​common/​quantization/​data_generators.py Simplifies ranges and fallback selection.
src/​nncf/​scopes.py Uses bulk set updates.
src/​nncf/​quantization/​algorithms/​weight_compression/​torch_backend.py Simplifies exception raising.
src/​nncf/​quantization/​algorithms/​weight_compression/​onnx_backend.py Simplifies exception raising.
src/​nncf/​quantization/​algorithms/​bias_correction/​algorithm.py Simplifies fallback selection.
src/​nncf/​openvino/​rt_info.py Simplifies path defaulting.
src/​nncf/​openvino/​graph/​transformations/​commands.py Simplifies exception raising.
src/​nncf/​openvino/​graph/​node_utils.py Uses max for dimension clamping.
src/​nncf/​onnx/​graph/​onnx_helper.py Simplifies directory defaulting.
src/​nncf/​experimental/​torch/​fx/​transformations.py Simplifies comparisons and defaulting.
src/​nncf/​experimental/​torch/​fx/​nncf_graph_builder.py Simplifies singleton comparisons.
src/​nncf/​experimental/​common/​graph/​netron.py Uses pathlib for binary output.
src/​nncf/​errors.py Removes redundant pass statements.
src/​nncf/​common/​utils/​patcher.py Uses an f-string for object paths.
src/​nncf/​common/​quantization/​quantizer_propagation/​solver.py Simplifies defaulting and set updates.
src/​nncf/​common/​hardware/​config.py Removes a redundant pass.
src/​nncf/​common/​graph/​model_transformer.py Simplifies exception raising.
src/​nncf/​common/​graph/​graph.py Uses bulk set updates.
src/​nncf/​common/​deprecation.py Uses an f-string for messages.
src/​custom_version.py Uses explicit regex flag names.
pyproject.toml Enables rule sets and sorts configuration lists.
examples/​post_training_quantization/​torch/​ssd300_vgg16/​main.py Iterates directly over file lines.
examples/​llm_compression/​torch/​gptq_model_convertor/​main.py Simplifies blank-line printing.
examples/​llm_compression/​openvino/​tiny_llama_find_hyperparams/​main.py Applies the conventional datetime alias.

Review effort: Balanced

Comment thread src/nncf/common/graph/graph.py
@AlexanderDokuchaev
AlexanderDokuchaev merged commit 8204b33 into openvinotoolkit:develop Oct 22, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NNCF Common Pull request that updates NNCF Common NNCF ONNX Pull requests that updates NNCF ONNX NNCF OpenVINO Pull requests that updates NNCF OpenVINO NNCF PT Pull requests that updates NNCF PyTorch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants