From aec6ded34ddcb79bf129bf7316a70b8f67b8c6ce Mon Sep 17 00:00:00 2001 From: "Arav K." Date: Tue, 20 Aug 2024 14:03:12 +0100 Subject: [PATCH] [beetsplug/fish] Eliminate some warnings - Fixed a 'mypy' error regarding 'set' - Print an error if unnecessary arguments are added --- beetsplug/fish.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/beetsplug/fish.py b/beetsplug/fish.py index cd1045756b..4778f0d186 100644 --- a/beetsplug/fish.py +++ b/beetsplug/fish.py @@ -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 @@ -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", @@ -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) @@ -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():