Conversation
|
Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6440 +/- ##
==========================================
+ Coverage 69.55% 69.60% +0.04%
==========================================
Files 141 144 +3
Lines 18498 18524 +26
Branches 3026 3026
==========================================
+ Hits 12867 12893 +26
Misses 4995 4995
Partials 636 636
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Refactors UI utilities out of beets/ui/__init__.py into focused modules under beets/util/ (color, diff, layout). Layout functions are converted from printing directly to yielding lines.
Changes:
- Moved colorization utilities to
beets/util/color.py, diff utilities tobeets/util/diff.py, and layout utilities tobeets/util/layout.py - Converted
print_column_layout/print_newline_layoutto generators (get_column_layout/get_newline_layout) - Relocated tests alongside new modules and removed duplicates from UI tests
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| beets/util/color.py | New module with ANSI color constants and colorize/uncolorize functions |
| beets/util/diff.py | New module with colordiff, field_diff, get_model_changes |
| beets/util/layout.py | New module with indent, split_into_lines, get_column/newline_layout generators |
| beets/ui/init.py | Removed moved code, delegates to new modules |
| beets/ui/commands/import_/display.py | Updated imports to use new modules |
| beets/ui/commands/import_/session.py | Updated imports to use new modules |
| beets/ui/commands/move.py | Updated import for colordiff |
| beets/ui/commands/update.py | Updated import for colorize |
| beetsplug/play.py | Updated import for colorize |
| beetsplug/importsource.py | Updated import for colorize |
| beetsplug/fetchart.py | Updated import for colorize |
| beetsplug/badfiles.py | Updated import for colorize |
| test/util/test_color.py | New tests for color utilities |
| test/util/test_diff.py | Updated patch path for _colorize |
| test/util/test_layout.py | New tests for layout utilities |
| test/ui/test_ui.py | Removed duplicated ShowModelChangeTest |
| test/ui/commands/test_import.py | Removed duplicated color/layout tests |
| .git-blame-ignore-revs | Added commit hashes for refactor |
You can also share your feedback on Copilot code review. Take the survey.
df40b1b to
c6f7463
Compare
c6f7463 to
95ccfa7
Compare
95ccfa7 to
ae3531d
Compare
- Add `get_model_changes` as the public API for computing diffs - Remove tests for `show_model_changes` as test_diff.py fully covers them.
3180de3 to
f62d29a
Compare
f62d29a to
41c835d
Compare
| `new` when `old` is not provided. When `fields` is given, only those | ||
| fields are considered. The `mtime` field is always excluded. | ||
| """ | ||
| old = old or new.get_fresh_from_db() |
There was a problem hiding this comment.
Because this was moved here from show_model_changes, the old in show_model_changes no longer gets set. This causes None to be printed for the track info in mbsync.
Refactor: Extract UI utilities into
beets/utilThis PR decouples terminal/display utilities from
beets/uiby moving them into focused modules underbeets/util. No user-facing behaviour changes.What moved where
colorize,uncolorize,color_len,color_split, ANSI constantsbeets/ui/__init__.pybeets/util/color.pycolordiff,_field_diff,get_model_changesbeets/ui/__init__.pybeets/util/diff.pyindent,split_into_lines,print_column_layout,print_newline_layoutbeets/ui/__init__.pybeets/util/layout.pyNotable design change in
layout.pyprint_column_layout/print_newline_layoutpreviously calledui.print_()internally, creating a hard dependency onbeets.ui. They are now renamed toget_column_layout/get_newline_layoutand converted to generators, yielding lines instead of printing them. The caller (display.py) is responsible for printing viaui.print_().New public API
get_model_changesis introduced inbeets/util/diff.pyas the pure, testable function for computing field-level diffs.show_model_changesinbeets/uinow delegates to it.Tests
test/util/test_color.py,test/util/test_diff.py,test/util/test_layout.py.ShowModelChangeTestfromtest/ui/test_ui.py— coverage is preserved intest/util/test_diff.py.