chore: TETRA-2181 — ruff baseline về 0 + gate full ruff check #166

Merged
tant merged 1 commit from fix/TETRA-2181-ruff-baseline-zero into main 2026-06-17 14:20:41 +07:00
Owner

Summary

Đưa ruff baseline toàn repo vhrms 582 → 0 và đổi CI gate từ ruff check --select S110 sang full ruff check . (chặn regression). Follow-up của TETRA-2134.

Cách làm

  • pyproject ignore RUF001/002/003 — ký tự Unicode tiếng Việt trong string/docstring/comment là CỐ Ý (≈247 lỗi).
  • Autofix safe + targeted --unsafe-fixes cho rule cơ học (I001 import-sort, RUF100, UP015/030/032, RUF005/010/012/013/022/034, B007/B905, F841...) — ≈300 lỗi. F841-fix giữ nguyên các call có side-effect (frappe.db.sql, sys.modules.setdefault), chỉ bỏ binding.
  • Thủ công: gỡ bare-expression cruft (flt()/Alignment() vô nghĩa do F841-fix để lại), simplify ternary RUF034 (2 nhánh giống hệt — latent smell), đổi loop _ trùng gettext _ (F402), ClassVar cho mutable class attr test (RUF012).
  • UP038 isinstance(x,(A,B))isinstance(x, A|B) — hợp lệ py3.10; rule này ruff mới đã bỏ nhưng 0.8.1 (CI pin) còn → fix để clean cả 2 version.
  • CI .forgejo/workflows/test.yml: gate full ruff check ..

Test Plan

  • ruff check . = 0 dưới CẢ ruff 0.8.1 (CI pin) lẫn 0.15.17 (latest)
  • 12 test file liên quan (payroll/overtime/leave/npt/asset/salary...) chạy per-file đều OK
  • Không đổi runtime — chỉ dọn lint (gỡ unused/dead, simplify, isinstance union)
  • CI "Lint — ruff (full check)" xanh trên PR

150 files (phần lớn là I001 import-sort autofix), net −111 dòng.

🤖 Generated with Claude Code

## Summary Đưa ruff baseline toàn repo vhrms **582 → 0** và đổi CI gate từ `ruff check --select S110` sang **full `ruff check .`** (chặn regression). Follow-up của TETRA-2134. ### Cách làm - **pyproject** ignore `RUF001/002/003` — ký tự Unicode tiếng Việt trong string/docstring/comment là CỐ Ý (≈247 lỗi). - **Autofix** safe + targeted `--unsafe-fixes` cho rule cơ học (I001 import-sort, RUF100, UP015/030/032, RUF005/010/012/013/022/034, B007/B905, F841...) — ≈300 lỗi. F841-fix giữ nguyên các call có side-effect (`frappe.db.sql`, `sys.modules.setdefault`), chỉ bỏ binding. - **Thủ công**: gỡ bare-expression cruft (flt()/Alignment() vô nghĩa do F841-fix để lại), simplify ternary RUF034 (2 nhánh giống hệt — latent smell), đổi loop `_` trùng gettext `_` (F402), ClassVar cho mutable class attr test (RUF012). - **UP038** `isinstance(x,(A,B))` → `isinstance(x, A|B)` — hợp lệ py3.10; rule này ruff mới đã bỏ nhưng 0.8.1 (CI pin) còn → fix để clean cả 2 version. - **CI** `.forgejo/workflows/test.yml`: gate full `ruff check .`. ### Test Plan - [x] `ruff check .` = **0** dưới CẢ ruff **0.8.1** (CI pin) lẫn **0.15.17** (latest) - [x] 12 test file liên quan (payroll/overtime/leave/npt/asset/salary...) chạy per-file đều **OK** - [x] Không đổi runtime — chỉ dọn lint (gỡ unused/dead, simplify, isinstance union) - [ ] CI "Lint — ruff (full check)" xanh trên PR *150 files (phần lớn là I001 import-sort autofix), net −111 dòng.* 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chore: TETRA-2181 — ruff baseline về 0 + gate full ruff check trong CI
All checks were successful
Test (offline) / test (push) Successful in 29s
Test (offline) / test (pull_request) Successful in 58s
2dc30d15da
Đưa baseline ruff toàn repo từ 582 lỗi về 0 và đổi CI gate từ
`ruff check --select S110` sang full `ruff check .` để chặn regression.

Cách làm:
- pyproject: ignore RUF001/002/003 (ký tự Unicode tiếng Việt trong
  string/docstring/comment — cố ý, không phải lỗi). Gỡ ~247 lỗi.
- `ruff check --fix` (safe) + targeted `--unsafe-fixes` cho rule cơ học
  (I001 import-sort, RUF100 noqa thừa, UP015/UP030/UP032, RUF005/010/012/013
  /022/034, B007/B905, F841...). Gỡ ~300.
- Thủ công: gỡ bare-expression cruft do F841-fix để lại (flt()/Alignment()
  vô nghĩa), đơn giản hoá ternary RUF034 (2 nhánh giống nhau), đổi loop var
  `_` trùng import gettext `_` (F402), ClassVar cho mutable class attr (test).
- UP038: đổi `isinstance(x,(A,B))` → `isinstance(x, A|B)` (hợp lệ py3.10;
  rule này newer ruff đã bỏ nhưng 0.8.1 còn — fix để clean cả 2 version).
- CI `.forgejo/workflows/test.yml`: gate full `ruff check .`.

Verify: `ruff check .` = 0 dưới CẢ ruff 0.8.1 (CI pin) lẫn 0.15.17 (latest);
12 test file liên quan (payroll/overtime/leave/npt/asset...) chạy per-file OK.
Không đổi runtime — chỉ dọn lint (gỡ unused/dead, simplify, isinstance union).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
tant merged commit 37a901187f into main 2026-06-17 14:20:41 +07:00
tant deleted branch fix/TETRA-2181-ruff-baseline-zero 2026-06-17 14:20:41 +07:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
tant/vhrms!166
No description provided.