Skip to content

autobpm: Add --force and --quiet options; Deprecate overwrite#6481

Open
JOJ0 wants to merge 11 commits intomasterfrom
autobpm_force_option
Open

autobpm: Add --force and --quiet options; Deprecate overwrite#6481
JOJ0 wants to merge 11 commits intomasterfrom
autobpm_force_option

Conversation

@JOJ0
Copy link
Copy Markdown
Member

@JOJ0 JOJ0 commented Mar 31, 2026

Description

Reveal the overwrite config setting to the CLI and at the same time deprecate the option name. It should be named force to streamline with other beets configs of the same kind.

  • Documentation. (If you've added a new command-line flag, for example, find the appropriate page under docs/ to describe it.)
  • Changelog. (Add an entry to docs/changelog.rst to the bottom of one of the lists near the top of the document.)
  • Tests. (Very much encouraged but not strictly required.)

@JOJ0 JOJ0 requested a review from a team as a code owner March 31, 2026 06:37
@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.

@JOJ0 JOJ0 marked this pull request as draft March 31, 2026 06:38
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

❌ Patch coverage is 60.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.01%. Comparing base (712bada) to head (80fcbe6).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
beetsplug/autobpm.py 60.00% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6481      +/-   ##
==========================================
- Coverage   70.01%   70.01%   -0.01%     
==========================================
  Files         146      146              
  Lines       18505    18514       +9     
  Branches     3010     3012       +2     
==========================================
+ Hits        12957    12962       +5     
- Misses       4920     4923       +3     
- Partials      628      629       +1     
Files with missing lines Coverage Δ
beetsplug/autobpm.py 71.69% <60.00%> (-3.31%) ⬇️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JOJ0 JOJ0 force-pushed the autobpm_force_option branch from 79fa4e2 to 4b75c68 Compare March 31, 2026 20:39
@JOJ0 JOJ0 changed the title autobpm: Support --force for overwrite config autobpm: Support --force and deprecate overwrite setting Mar 31, 2026
@JOJ0 JOJ0 changed the title autobpm: Support --force and deprecate overwrite setting autobpm: Support --force and deprecate overwrite setting Mar 31, 2026
JOJ0 added a commit that referenced this pull request Mar 31, 2026
JOJ0 added a commit that referenced this pull request Mar 31, 2026
@JOJ0 JOJ0 force-pushed the autobpm_force_option branch from 227b179 to 8621fa8 Compare March 31, 2026 20:48
@JOJ0 JOJ0 marked this pull request as ready for review March 31, 2026 20:48
@JOJ0 JOJ0 force-pushed the autobpm_force_option branch from 8621fa8 to 2832cc5 Compare March 31, 2026 21:09
When batch bpm computing, the plugin's output is very noisy. This change
allows hiding "BPM already exists for item" logs with a new `--quiet`
option (or config setting)
)

def imported(self, _, task: ImportTask) -> None:
self.calculate_bpm(task.imported_items())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this also obey force and quiet from the config?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

good point! will fix!

@JOJ0 JOJ0 marked this pull request as draft March 31, 2026 22:10
@JOJ0 JOJ0 marked this pull request as draft March 31, 2026 22:10
@JOJ0 JOJ0 changed the title autobpm: Support --force and deprecate overwrite setting autobpm: Add --force and --quiet options; Deprecate overwrite Apr 1, 2026
@JOJ0 JOJ0 marked this pull request as ready for review April 1, 2026 07:06
@JOJ0 JOJ0 requested review from Copilot and jackwilsdon April 1, 2026 07:06
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

This PR update autobpm plugin so user can overwrite existing BPM via new force name (config + CLI), and hide “already has bpm” message via quiet. It also start deprecate old overwrite config name.

Changes:

  • Add --force/-f and --quiet/-q flags to beet autobpm, and thread force/quiet through BPM calculation.
  • Add config keys force and quiet, and deprecate overwrite (with user warning).
  • Update docs and changelog to mention new options and deprecation.

Reviewed changes

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

File Description
beetsplug/autobpm.py Add force/quiet config + CLI flags; deprecate overwrite and map it to force; adjust logging/skip logic.
docs/plugins/autobpm.rst Document new config defaults; add force/quiet; mark overwrite deprecated.
docs/changelog.rst Add Unreleased changelog bullets for new force + --quiet.

Comment on lines +78 to 108
def command(self, lib: Library, opts, args: list[str]) -> None:
force = self.config["force"].get(bool) or opts.force
quiet = self.config["quiet"].get(bool) or opts.quiet
self.calculate_bpm(
list(lib.items(args)),
write=should_write(),
force=force,
quiet=quiet,
)

def imported(self, _, task: ImportTask) -> None:
self.calculate_bpm(task.imported_items())
self.calculate_bpm(
task.imported_items(),
force=self.config["force"].get(bool),
quiet=self.config["quiet"].get(bool),
)

def calculate_bpm(self, items: list[Item], write: bool = False) -> None:
def calculate_bpm(
self,
items: list[Item],
write: bool = False,
force: bool = False,
quiet: bool = False,
) -> None:
for item in items:
path = item.filepath
if bpm := item.bpm:
self._log.info("BPM for {} already exists: {}", path, bpm)
if not self.config["overwrite"]:
if not quiet:
self._log.info("BPM for {} already exists: {}", path, bpm)
if not force:
continue
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

grug see new force/quiet behavior and deprecated overwrite path, but tests not check: (1) --force overwrites existing bpm, (2) --quiet suppresses log, (3) overwrite config still works + warns. please add regression tests in existing test/plugins/test_autobpm.py so behavior not break later.

Copilot uses AI. Check for mistakes.
@JOJ0
Copy link
Copy Markdown
Member Author

JOJ0 commented Apr 1, 2026

Docs render and relevant parts look like this (first time I actually use the conf directives and the deprecations features. Very nice stuff! Love it @snejus) Hope I did it correctly since it doesnt state which version we will throw it out? (The logs say that this is with 3.0.0, so i guess when we deprecate something we will always until next major release which is allowed to include breaking changes, right?)

Screenshot 2026-04-01 at 09 07 41

@jackwilsdon appreciate a final review :-)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@JOJ0 JOJ0 force-pushed the autobpm_force_option branch from e5f66e8 to 48bf094 Compare April 1, 2026 07:26
Copy link
Copy Markdown
Member

@jackwilsdon jackwilsdon left a comment

Choose a reason for hiding this comment

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

Looks good 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants