Skip to content

refactor: rewrite code for improved clarity and consistency#1940

Closed
wkentaro wants to merge 1 commit intomainfrom
refactor/rewrite-external-contributions
Closed

refactor: rewrite code for improved clarity and consistency#1940
wkentaro wants to merge 1 commit intomainfrom
refactor/rewrite-external-contributions

Conversation

@wkentaro
Copy link
Copy Markdown
Owner

@wkentaro wkentaro commented Apr 9, 2026

Summary

  • Rewrite various code sections across 8 core modules for better readability, more idiomatic patterns, and consistent style
  • Use IntEnum for shape point style and vertex mode constants instead of raw integers
  • Restructure control flow with guard clauses and early returns throughout canvas, app, and label dialog
  • Improve variable naming across canvas (boundedMoveShapes, offsetToCenter, event handlers), app (scaleFitWindow, deleteFile, maybeSave), and shape modules
  • Extract magic numbers to named constants in file_dialog_preview.py
  • Use pathlib for file detection in __main__.py
  • Consolidate flag widget management in label_dialog.py

Why

Improve code clarity, reduce nesting depth, and adopt more consistent idiomatic Python patterns across the codebase.

Test plan

  • All 125 tests pass (make test)
  • Import verification for all modified modules
  • Manual verification of annotation workflows (draw polygon, move shapes, brightness/contrast dialog, file preview dialog)

@wkentaro wkentaro self-assigned this Apr 9, 2026
Rewrite various code sections across core modules for better readability,
more idiomatic patterns, and consistent style:

- shape.py: use IntEnum for point style/vertex mode constants, restructure
  control flow with guard clauses, improve variable naming
- canvas.py: rewrite boundedMoveShapes with clearer clamping logic, improve
  offsetToCenter variable naming, restructure event handlers
- app.py: simplify scaleFitWindow with explicit min-based scaling, improve
  deleteFile/maybeSave flow with early returns, better variable names
- label_dialog.py: consolidate flag widget management, extract helper methods
- file_dialog_preview.py: extract magic numbers to named constants
- brightness_contrast_dialog.py: use descriptive callback naming
- __main__.py: use pathlib for file detection
- utils/shape.py: minor expression cleanup

All tests pass. No behavioral changes.
@wkentaro wkentaro force-pushed the refactor/rewrite-external-contributions branch from b420a95 to 5ae582f Compare April 9, 2026 13:58
@wkentaro wkentaro closed this Apr 10, 2026
@wkentaro wkentaro deleted the refactor/rewrite-external-contributions branch April 10, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant