Skip to content

Commit

Permalink
[beetsplug/fish] Eliminate some warnings
Browse files Browse the repository at this point in the history
- Fixed a 'mypy' error regarding 'set'

- Print an error if unnecessary arguments are added
  • Loading branch information
Arav K. committed Sep 4, 2024
1 parent 1d52a4a commit d217861
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions beetsplug/fish.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import os
import textwrap
from pathlib import Path
from typing import Dict, Iterable, List, Optional, cast
from typing import Dict, Iterable, List, Optional, Set, cast

import beets.ui.commands
from beets import library, ui
Expand Down Expand Up @@ -271,6 +271,7 @@ def commands(self) -> List[ui.Subcommand]:
"-e",
"--extravalues",
action="append",
default=[],
type="choice",
choices=library.Item.all_keys() + library.Album.all_keys(),
help="complete the known values of the specified metadata fields",
Expand All @@ -293,10 +294,13 @@ def run(
args: List[str],
):
# Get the user-provided options.
include_fields = not getattr(opts, "noFields")
extra_comp_fields = cast(List[str], getattr(opts, "extravalues") or [])
output = Path(getattr(opts, "output"))
assert len(args) == 0
include_fields = not opts.noFields
extra_comp_fields = cast(List[str], opts.extravalues)
output = Path(opts.output)

if len(args) != 0:
print("The 'fish' command does not accept any arguments!")
exit(1)

# Try to ensure we will be able to write the output file.
output.parent.mkdir(parents=True, exist_ok=True)
Expand Down Expand Up @@ -378,7 +382,7 @@ def run(

if extra_comp_fields:
# The set of values for every user-specified extra field.
extra_values: Dict[str, set[str]] = dict.fromkeys(
extra_values: Dict[str, Set[str]] = dict.fromkeys(
extra_comp_fields, set()
)
for item in lib.items():
Expand Down

0 comments on commit d217861

Please sign in to comment.