Skip to content

Remove lib parameter from _raw_main and _setup#6547

Merged
semohr merged 3 commits intomasterfrom
cleanup_ui_lib_test_setup
Apr 22, 2026
Merged

Remove lib parameter from _raw_main and _setup#6547
semohr merged 3 commits intomasterfrom
cleanup_ui_lib_test_setup

Conversation

@semohr
Copy link
Copy Markdown
Contributor

@semohr semohr commented Apr 18, 2026

Description

The lib parameter on _raw_main and _setup was only used by the test harness. Rather than keep testing-specific logic in production code, this PR removes the parameter and updates the test harness to patch _open_library instead.

  • Changelog. (Not needed as this is a purely internal factor imo)

@semohr semohr requested a review from a team as a code owner April 18, 2026 18:27
@semohr semohr added refactor testing Relates to the testing/CI infrastructure labels Apr 18, 2026
Copilot AI review requested due to automatic review settings April 18, 2026 18:27
@github-actions
Copy link
Copy Markdown

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
Copy link
Copy Markdown

codecov Bot commented Apr 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.77%. Comparing base (e550482) to head (7f48672).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6547      +/-   ##
==========================================
- Coverage   71.77%   71.77%   -0.01%     
==========================================
  Files         159      159              
  Lines       20531    20528       -3     
  Branches     3266     3264       -2     
==========================================
- Hits        14737    14734       -3     
  Misses       5105     5105              
  Partials      689      689              
Files with missing lines Coverage Δ
beets/ui/__init__.py 82.11% <100.00%> (-0.13%) ⬇️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

PR remove lib param from CLI bootstrap (_raw_main / _setup). Goal: keep test-only hook out of prod code. grug like that idea.

Changes:

  • Remove lib injection path from beets.ui._setup and beets.ui._raw_main; always open library via _open_library.
  • Update test harness RunMixin.run_command to patch beets.ui._open_library instead of passing lib into _raw_main.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
beets/ui/init.py Drop lib argument from CLI internals and always close opened library.
beets/test/helper.py Switch tests to patch _open_library and stub lib._close to keep shared lib alive.
Comments suppressed due to low confidence (1)

beets/ui/init.py:1000

  • grug see main now need args always. packaging entrypoint beet = "beets.ui:main" call main() with no args, so runtime TypeError. make args optional (default None) and when None set to sys.argv[1:] before call _raw_main.
def main(args: list[str]) -> None:
    """Run the main command-line interface for beets. Includes top-level
    exception handlers that print friendly error messages.
    """
    if "AppData\\Local\\Microsoft\\WindowsApps" in sys.exec_prefix:

Comment thread beets/test/helper.py
Comment thread beets/test/helper.py Outdated
Comment thread beets/test/helper.py
@semohr semohr changed the title Remove lib parameter from _raw_main and `_setup Remove lib parameter from _raw_main and _setup Apr 18, 2026
@semohr semohr force-pushed the cleanup_ui_lib_test_setup branch 3 times, most recently from 5146bf0 to f258c3a Compare April 19, 2026 13:29
@semohr semohr force-pushed the cleanup_ui_lib_test_setup branch from f258c3a to 5120e59 Compare April 19, 2026 16:11
@semohr semohr enabled auto-merge April 19, 2026 16:11
@semohr semohr force-pushed the cleanup_ui_lib_test_setup branch from 5120e59 to 7f48672 Compare April 22, 2026 20:20
@semohr semohr merged commit a4ad7d4 into master Apr 22, 2026
19 checks passed
@semohr semohr deleted the cleanup_ui_lib_test_setup branch April 22, 2026 20:25
snejus added a commit that referenced this pull request Apr 22, 2026
Fix regression error from #6547.

Default value `None` is needed for main function, was removed
accidentally.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor testing Relates to the testing/CI infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants