more linting
This commit is contained in:
parent
7775022ef4
commit
d5ba12b265
5 changed files with 14 additions and 9 deletions
|
|
@ -24,6 +24,7 @@ from ytdl_sub.utils.exceptions import StringFormattingException
|
||||||
from ytdl_sub.validators.string_formatter_validators import is_valid_source_variable_name
|
from ytdl_sub.validators.string_formatter_validators import is_valid_source_variable_name
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
|
# pylint: disable=too-many-branches
|
||||||
|
|
||||||
|
|
||||||
class ArgumentParser(Enum):
|
class ArgumentParser(Enum):
|
||||||
|
|
@ -367,7 +368,8 @@ class _Parser:
|
||||||
|
|
||||||
self._pos += 1
|
self._pos += 1
|
||||||
return UnresolvedMap(value=output)
|
return UnresolvedMap(value=output)
|
||||||
elif ch == ",":
|
|
||||||
|
if ch == ",":
|
||||||
if in_comma:
|
if in_comma:
|
||||||
raise UNEXPECTED_COMMA_ARGUMENT(ArgumentParser.MAP_KEY)
|
raise UNEXPECTED_COMMA_ARGUMENT(ArgumentParser.MAP_KEY)
|
||||||
if key is not None:
|
if key is not None:
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ class Script:
|
||||||
return override_name.startswith("%")
|
return override_name.startswith("%")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _function_name(self, function_key: str) -> str:
|
def _function_name(cls, function_key: str) -> str:
|
||||||
return function_key[1:]
|
return function_key[1:]
|
||||||
|
|
||||||
def __init__(self, overrides: Dict[str, str]):
|
def __init__(self, overrides: Dict[str, str]):
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,9 @@ class BuiltInFunction(Function):
|
||||||
if is_union(arg.output_type):
|
if is_union(arg.output_type):
|
||||||
# TODO: Move naming to separate function, deal with Union input naming
|
# TODO: Move naming to separate function, deal with Union input naming
|
||||||
received_type_names.append(
|
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:
|
else:
|
||||||
received_type_names.append(f"%{arg.name}(...)->{arg.output_type.type_name()}")
|
received_type_names.append(f"%{arg.name}(...)->{arg.output_type.type_name()}")
|
||||||
|
|
|
||||||
|
|
@ -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.resolvable import Resolvable
|
||||||
from ytdl_sub.script.types.variable import FunctionArgument
|
from ytdl_sub.script.types.variable import FunctionArgument
|
||||||
from ytdl_sub.script.types.variable import Variable
|
from ytdl_sub.script.types.variable import Variable
|
||||||
|
from ytdl_sub.script.utils.exceptions import UNREACHABLE
|
||||||
from ytdl_sub.utils.exceptions import StringFormattingException
|
from ytdl_sub.utils.exceptions import StringFormattingException
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -17,12 +18,12 @@ class VariableDependency(ABC):
|
||||||
@property
|
@property
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def variables(self) -> Set[Variable]:
|
def variables(self) -> Set[Variable]:
|
||||||
raise NotImplemented()
|
raise NotImplemented
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def function_arguments(self) -> Set[FunctionArgument]:
|
def function_arguments(self) -> Set[FunctionArgument]:
|
||||||
raise NotImplemented()
|
raise NotImplemented
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def resolve(
|
def resolve(
|
||||||
|
|
@ -30,10 +31,11 @@ class VariableDependency(ABC):
|
||||||
resolved_variables: Dict[Variable, Resolvable],
|
resolved_variables: Dict[Variable, Resolvable],
|
||||||
custom_functions: Dict[str, "VariableDependency"],
|
custom_functions: Dict[str, "VariableDependency"],
|
||||||
) -> Resolvable:
|
) -> Resolvable:
|
||||||
raise NotImplemented()
|
raise NotImplemented
|
||||||
|
|
||||||
|
@classmethod
|
||||||
def _resolve_argument_type(
|
def _resolve_argument_type(
|
||||||
self,
|
cls,
|
||||||
arg: ArgumentType,
|
arg: ArgumentType,
|
||||||
resolved_variables: Dict[Variable, Resolvable],
|
resolved_variables: Dict[Variable, Resolvable],
|
||||||
custom_functions: Dict[str, "VariableDependency"],
|
custom_functions: Dict[str, "VariableDependency"],
|
||||||
|
|
@ -49,7 +51,7 @@ class VariableDependency(ABC):
|
||||||
resolved_variables=resolved_variables, custom_functions=custom_functions
|
resolved_variables=resolved_variables, custom_functions=custom_functions
|
||||||
)
|
)
|
||||||
|
|
||||||
assert False, "never reach here"
|
raise UNREACHABLE
|
||||||
|
|
||||||
@final
|
@final
|
||||||
def has_variable_dependency(self, resolved_variables: Dict[Variable, Resolvable]) -> bool:
|
def has_variable_dependency(self, resolved_variables: Dict[Variable, Resolvable]) -> bool:
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import sys
|
||||||
from typing import List
|
from typing import List
|
||||||
from typing import TypeVar
|
from typing import TypeVar
|
||||||
|
|
||||||
from ytdl_sub.script.utils.exceptions import InvalidSyntaxException
|
|
||||||
from ytdl_sub.script.utils.exceptions import UserException
|
from ytdl_sub.script.utils.exceptions import UserException
|
||||||
|
|
||||||
TUserException = TypeVar("TUserException", bound=UserException)
|
TUserException = TypeVar("TUserException", bound=UserException)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue