Enable flake8-bugbear (B) and review further ruff rule sets
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- data, developer-experience, testing
Hướng nghiên cứu
Start by checking linked PR #74, since it may already cover this work. The rule set is in pyproject.toml; add B and ignore B008. The five delete-value setters in mikecore/DfsBuilder.py (around lines 124-160) need self.__CheckBuildStage1() with the parentheses added, and tests/examples_dfsu.py (line 297) and tests/test_dfsu_file.py (line 1264) hold the two stray expressions. Done when ruff reports no B findings, the pre-commit hooks pass, and a new test shows that setting a delete value after CreateFile raises an error.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Why
Five DfsBuilder delete-value setters never run their build-stage check, because the call is missing its parentheses:
def SetDeleteValueDouble(self, value):
self.__CheckBuildStage1 # looks the method up, never calls it
self.FileInfo.DeleteValueDouble = value
The same line is in SetDeleteValueFloat, SetDeleteValueByte, SetDeleteValueInt and SetDeleteValueUnsignedInt (L124, L133, L142, L151, L160). Every other setter calls self.__CheckBuildStage1(). So a delete value can be changed after CreateFile without an error, after the header has already been written.
The same rule finds two more bugs in the tests:
tests/examples_dfsu.py#L297: a baretopLayerOffset, left over from a C# declaration, reads a local before it is assigned. SoExtractDfsu2DLayerFrom3DraisedNameErroron every call. It is fixed in #66.tests/test_dfsu_file.py#L1264: a bareAssert.IsTruethat is never called, so that line asserts nothing.
None of our checks reports these. Ruff runs only E4, E7, E9, F and UP (pyproject.toml), and none of those rules looks at expressions whose value is discarded. A type checker (pyrefly, #66) accepts an uncalled bound method as a valid expression. flake8-bugbear's B018 (useless expression) finds exactly these 7 lines and nothing else.
Proposal
Add the bugbear rules (B) to ruff's select, ignoring B008, and fix what they report. On master that is 29 findings:
| Rule | Hits | Finding |
|---|---|---|
B018 useless expression |
7 | The 5 setters and the 2 test lines above. Real bugs. |
B017 pytest.raises(Exception) |
4 | tests/test_dfsbuilder.py. These pass on any error, including one caused by a bug. Add match=. |
B904 raise in except without from |
11 | SetNodes in both builders and MeshFile. Adding from err keeps the cause in the traceback. |
B007 unused loop variable |
3 | Rename to _j / _i. |
B008 call in a default argument |
4 | Not bugs (DfsParameters() is never mutated, np.float32 is immutable), so ignore the rule. B006 (mutable defaults) still applies. |
The rules with no findings today are still worth having in a codebase ported from C#: B015 (a comparison used as a statement, where an assert was meant), B011 (assert False), B023 (a closure over a loop variable), B006 (a mutable default argument) and B905 (zip() without strict=, which #66's new tests would trip).
Once B is in, other rule sets could be reviewed the same way, each with its findings on master. Candidates are PT (pytest style), SIM, and PL errors (PLE).
Done when
selectincludesB,B008is ignored with a reason, anduvx pre-commit run --all-filespasses.- The 5 setters call
self.__CheckBuildStage1(), with a test that setting a delete value afterCreateFileraises an error.
- Ngôn ngữ chính
- Python
- Star
- 5
- Fork
- 1
- Merge trung bình
- 1 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 16
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của DHI/mikecore-python
-
Four test assertions carried over from the C# suite are still commented outCó thể đã có người làm @ryan-kipawa đã nhận 16 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
DHI/mikecore-python#49 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bugs found while adding type checking (#66), not yet fixedCó thể đã có người làm @ryan-kipawa đã nhận 3 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
DHI/mikecore-python#72 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
DHI/mikecore-python#59 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
New submesh feature (2027) makes all dfsu fail!Có thể đã có người làm @ryan-kipawa đã nhận 16 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
DHI/mikecore-python#54 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Remaining TODOs in production code: platform notes, licensing questions, and one likely-stale markerĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
DHI/mikecore-python#51 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của DHI/mikecore-python
Issue tương tự
-
mermaid_extract.py silently discards single-line state-diagram notes; sequence notes are keptĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
cathrynlavery/diagram-design#441 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Cleanup] Include the public header in work_split.cppCó thể đã có người làm @blozano-tt đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
tenstorrent/tt-metal#60850 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
backend::sglang bug language::python observability
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
OpenShot/openshot-qt#6202 ·
Maintainer thường phản hồi trong vòng 1 ngày