Repository navigation
fix(examples): make the examples follow the rules they teach, and lint it - #431
Merged
Merged
Conversation
…t it Agents copy these scripts (bmesh-gear is the documented anatomy), but nothing checked them against the repo's own rules, and they broke them: 53 per-face `use_smooth` loops (three in bmesh-gear), 74 per-vertex `v.co.z += ...` loops, more per-element material/co writes, and seven `active_object` reads with no None guard. - 127 single-statement loops became foreach_set / foreach_get by a scripted AST rewrite (inline comments kept); seven more hand-converted (constant material indices, uniform co scale/offset, the moka-pot lean). - Eight loops with genuinely per-element logic (ring/station material bands, n-gon marking, ball-surface tests) carry a `# foreach-exempt: <why>` marker. - Seven `X = bpy.context.active_object` reads get `if X is None: raise`. - tests/check_example_rules.py (Validate) rejects an unmarked per-element write in a loop over .polygons/.vertices (Mesh-only names, so bmesh code is never hit) and an unguarded active_object read. Old and new versions of six scripts, run on 5.2.1 across ten paths including the touched falsifiers, print identical output with identical exit codes. Closes #400 Signed-off-by: TMHSDigital <154358121+TMHSDigital@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
CI evidence before merge: all checks pass ( 13 pass ). Blender Smoke on PR head: Blender 5.2.2 LTS / Blender 4.5.14 LTS. Summaries (happy path; falsifiers) per leg: 141 passed, 3 skipped, 0 failed;136 passed, 7 skipped, 0 failed;143 passed, 1 skipped, 0 failed;143 passed, 0 skipped, 0 failed; |
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.
Closes #400.
Problem
Agents copy these scripts (
bmesh-gearis the documented anatomy), but nothing checked them against the repo's own rules, and they broke them.Change
for p in X.polygons: p.use_smooth = EbecomesX.polygons.foreach_set("use_smooth", …). That is a constant fill whenEdoesn't usep, and a comprehension otherwise.for v in X.vertices: v.co.z += Dbecomesforeach_get→ shiftco[2::3]→foreach_set._conames in the same function (checked).material_indexfills: boolean-exact-volume, depsgraph-export, gn-sdf-remesh, soccer seams;coscale and offset: prop-origin-transform ×2, collision-hull--shrink-hull;--lean-pot.# foreach-exempt: <why>. These have genuinely per-element logic: car-mirror ring bands, collision-hull bonnet height, the lightmap post arc fit, mesh-hygiene n-gon marking, the soccer pentagon test, triangulate-tangents build-order bands, and the bowling-ball surface test.active_objectreads (compositor-glare, gn-sdf-remesh ×3, grease-pencil-rosette ×2, turntable) getif X is None: raise RuntimeError(...).tests/check_example_rules.pyin Validate. It flags:.polygons/.vertices. Those names exist only on Mesh, since BMesh usesfaces/verts, so bmesh code never triggers it;active_objectassignment not directly followed byif X is None.docs/new-example-prompt.mddocuments the lint and the marker.Evidence
Equivalence, live run. Binary reports 5.2.1 LTS. Each pair runs
main's script and this branch's:--lift-z--lean-pot·--lift-z--shrink-hull--invert-bind"Identical" excludes timing and temp-path lines. CI smoke runs every happy path and catalog falsifier on 5.2 and 4.5.
Checker: passes on 140 scripts. On
mainit reports 15 violations after the scripted pass, which are the hand-fixed and marked sites above.check_helper_drift,check_exit_code_readme,check_render_gates,check_engine_idandcheck_witnessespass. The gallery is unchanged: it links sources rather than inlining them.🤖 Generated with Claude Code