diff --git a/src/ytdl_sub/script/parser.py b/src/ytdl_sub/script/parser.py index 32f4ed19..c9d10df6 100644 --- a/src/ytdl_sub/script/parser.py +++ b/src/ytdl_sub/script/parser.py @@ -24,6 +24,7 @@ from ytdl_sub.utils.exceptions import StringFormattingException from ytdl_sub.validators.string_formatter_validators import is_valid_source_variable_name # pylint: disable=invalid-name +# pylint: disable=too-many-branches class ArgumentParser(Enum): @@ -367,7 +368,8 @@ class _Parser: self._pos += 1 return UnresolvedMap(value=output) - elif ch == ",": + + if ch == ",": if in_comma: raise UNEXPECTED_COMMA_ARGUMENT(ArgumentParser.MAP_KEY) if key is not None: diff --git a/src/ytdl_sub/script/script.py b/src/ytdl_sub/script/script.py index 8ae449cb..05db64b3 100644 --- a/src/ytdl_sub/script/script.py +++ b/src/ytdl_sub/script/script.py @@ -13,7 +13,7 @@ class Script: return override_name.startswith("%") @classmethod - def _function_name(self, function_key: str) -> str: + def _function_name(cls, function_key: str) -> str: return function_key[1:] def __init__(self, overrides: Dict[str, str]): diff --git a/src/ytdl_sub/script/types/function.py b/src/ytdl_sub/script/types/function.py index dce5e6ee..17f1bf09 100644 --- a/src/ytdl_sub/script/types/function.py +++ b/src/ytdl_sub/script/types/function.py @@ -228,7 +228,9 @@ class BuiltInFunction(Function): if is_union(arg.output_type): # TODO: Move naming to separate function, deal with Union input naming received_type_names.append( - f"%{arg.name}(...)->Union[{', '.join(arg_type.type_name() for arg_type in arg.output_type.__args__)}]" + f"%{arg.name}(...)->Union[" + f"{', '.join(type_.type_name() for type_ in arg.output_type.__args__)}" + f"]" ) else: received_type_names.append(f"%{arg.name}(...)->{arg.output_type.type_name()}") diff --git a/src/ytdl_sub/script/types/variable_dependency.py b/src/ytdl_sub/script/types/variable_dependency.py index 66e9f337..4bba7215 100644 --- a/src/ytdl_sub/script/types/variable_dependency.py +++ b/src/ytdl_sub/script/types/variable_dependency.py @@ -9,6 +9,7 @@ from ytdl_sub.script.types.resolvable import ArgumentType from ytdl_sub.script.types.resolvable import Resolvable from ytdl_sub.script.types.variable import FunctionArgument from ytdl_sub.script.types.variable import Variable +from ytdl_sub.script.utils.exceptions import UNREACHABLE from ytdl_sub.utils.exceptions import StringFormattingException @@ -17,12 +18,12 @@ class VariableDependency(ABC): @property @abstractmethod def variables(self) -> Set[Variable]: - raise NotImplemented() + raise NotImplemented @property @abstractmethod def function_arguments(self) -> Set[FunctionArgument]: - raise NotImplemented() + raise NotImplemented @abstractmethod def resolve( @@ -30,10 +31,11 @@ class VariableDependency(ABC): resolved_variables: Dict[Variable, Resolvable], custom_functions: Dict[str, "VariableDependency"], ) -> Resolvable: - raise NotImplemented() + raise NotImplemented + @classmethod def _resolve_argument_type( - self, + cls, arg: ArgumentType, resolved_variables: Dict[Variable, Resolvable], custom_functions: Dict[str, "VariableDependency"], @@ -49,7 +51,7 @@ class VariableDependency(ABC): resolved_variables=resolved_variables, custom_functions=custom_functions ) - assert False, "never reach here" + raise UNREACHABLE @final def has_variable_dependency(self, resolved_variables: Dict[Variable, Resolvable]) -> bool: diff --git a/src/ytdl_sub/script/utils/parser_exception_formatter.py b/src/ytdl_sub/script/utils/parser_exception_formatter.py index 64a326ea..c30e42bc 100644 --- a/src/ytdl_sub/script/utils/parser_exception_formatter.py +++ b/src/ytdl_sub/script/utils/parser_exception_formatter.py @@ -2,7 +2,6 @@ import sys from typing import List from typing import TypeVar -from ytdl_sub.script.utils.exceptions import InvalidSyntaxException from ytdl_sub.script.utils.exceptions import UserException TUserException = TypeVar("TUserException", bound=UserException)