Skip to content

chore: enable safe Ruff autofix rules#5774

Open
njzjz-bot wants to merge 3 commits into
deepmodeling:masterfrom
njzjz-bot:chore/enable-safe-ruff-autofix-rules
Open

chore: enable safe Ruff autofix rules#5774
njzjz-bot wants to merge 3 commits into
deepmodeling:masterfrom
njzjz-bot:chore/enable-safe-ruff-autofix-rules

Conversation

@njzjz-bot

@njzjz-bot njzjz-bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Enable eight Ruff rules that have safe, automatic fixes in the repository's pinned Ruff v0.15.18:

  • PIE808, PT022, RET502, SIM910, TD006
  • PLR1711, PLR1733, PLR2044

Intentional follow-up

This PR deliberately changes only pyproject.toml; it does not include the 128 existing code fixes. The configured pre-commit.ci autofix should apply those fixes to this PR, which provides an end-to-end confirmation that the automated repair is clean.

COM812 is intentionally excluded because ruff-format is already enabled and Ruff recommends against combining the formatter with this trailing-comma rule. Rules whose fixes are classified as unsafe in Ruff v0.15.18 are also excluded.

Validation

  • git diff --check
  • ruff v0.15.18 check --output-format json . reports exactly 128 intentional diagnostics from the eight newly enabled rules; no --fix was run.

Authored by OpenClaw (model: custom-chat-jinzhezeng-group/gpt-5.6-terra)

Summary by CodeRabbit

  • Bug Fixes

    • Improved attribute assignment handling to fully control weight/bias-related updates during tracing.
    • Ensured neighborhood-distance resolution is initialized from available runtime/tensor sources and saved consistently.
    • Improved test isolation by clearing leaked device contexts before tests.
  • Refactor

    • Simplified option lookups (optional fields/seed/precision mappings) and equivalent loop-bound expressions across models/kernels.
  • Chores

    • Expanded linting rules and removed stray placeholder comments/formatting artifacts across docs and code.

njzjz-bot and others added 2 commits July 12, 2026 11:11
Enable eight Ruff rules whose existing diagnostics are fixed safely by Ruff v0.15.18.\n\nDo not include the resulting source edits in this commit: pre-commit.ci should apply and commit them on the pull request.\n\nAuthored by OpenClaw (model: custom-chat-jinzhezeng-group/gpt-5.6-terra)
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a8496c92-cd2f-4ee3-9909-3788939a4cb9

📥 Commits

Reviewing files that changed from the base of the PR and between 9a4ec77 and 986e664.

📒 Files selected for processing (2)
  • deepmd/tf/nvnmd/descriptor/se_a.py
  • deepmd/tf/nvnmd/descriptor/se_atten.py
💤 Files with no reviewable changes (2)
  • deepmd/tf/nvnmd/descriptor/se_atten.py
  • deepmd/tf/nvnmd/descriptor/se_a.py

📝 Walkthrough

Walkthrough

This PR applies mechanical Python and Triton syntax simplifications, makes selected attribute-assignment exits explicit, updates NVNMD descriptor range initialization, expands Ruff lint rules, and cleans up test fixtures, helpers, comments, and equivalent loop forms.

Changes

Runtime consistency and syntax cleanup

Layer / File(s) Summary
Python runtime and data-path updates
deepmd/jax/..., deepmd/pd/..., deepmd/pt/..., deepmd/tf/..., deepmd/utils/...
Simplifies dict.get() calls, removes explicit None returns, adds explicit attribute-assignment exits, and preserves existing downstream behavior.
Kernel and tabulation loop normalization
deepmd/kernels/triton/..., deepmd/pt/optimizer/..., deepmd/tf/utils/..., deepmd/utils/tabulate_math.py
Rewrites equivalent range(0, ...) expressions using single-argument range(...) forms.
NVNMD descriptor initialization and cleanup
deepmd/tf/nvnmd/..., deepmd/tf/op/...
Resolves NVNMD neighborhood-distance bounds and updates configuration state; removes placeholder comment lines from NVNMD implementation paths.
Lint and supporting configuration
pyproject.toml, doc/conf.py
Enables eight additional Ruff rules and removes a standalone configuration comment.
Test helpers and fixture cleanup
source/tests/...
Updates mock state, comparison variables, equivalent loop forms, device-context cleanup fixtures, and placeholder test comments.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: iProzd, njzjz

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: enabling safe Ruff autofix rules.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@njzjz

njzjz commented Jul 12, 2026

Copy link
Copy Markdown
Member

pre-commit.ci autofix

@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.66667% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.56%. Comparing base (0c5a914) to head (986e664).

Files with missing lines Patch % Lines
deepmd/kernels/triton/sezm/so2_rotation.py 0.00% 6 Missing ⚠️
deepmd/tf/utils/tabulate.py 77.77% 2 Missing ⚠️
deepmd/pt/optimizer/hybrid_muon.py 0.00% 1 Missing ⚠️
deepmd/tf2/atomic_model/linear_atomic_model.py 0.00% 1 Missing ⚠️
deepmd/utils/tabulate_math.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5774      +/-   ##
==========================================
- Coverage   79.69%   79.56%   -0.14%     
==========================================
  Files        1020     1020              
  Lines      116359   116357       -2     
  Branches     4303     4305       +2     
==========================================
- Hits        92736    92581     -155     
- Misses      22076    22226     +150     
- Partials     1547     1550       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@njzjz njzjz requested a review from wanghan-iapcm July 12, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants