ref: typehints, enum instead of raw string, abc and other (#1)

Full code coverage with annotations, fixing errors in various linters: ruff, wps, etc. Fixing errors in type checkers: ty, mypy, pyright. Formatting and bringing code to a consistent style, applying best practices in various aspects.
This commit is contained in:
kolo
2025-10-08 13:37:31 +03:00
committed by GitHub
parent 22f1171192
commit 73303b1c08
45 changed files with 983 additions and 996 deletions
+15 -35
View File
@@ -1,4 +1,4 @@
from argparse import ArgumentParser
from argparse import ArgumentParser, Namespace
from argenta.orchestrator.argparser.arguments.models import (
BooleanArgument,
@@ -10,7 +10,7 @@ from argenta.orchestrator.argparser.arguments.models import (
class ArgParser:
def __init__(
self,
processed_args: list[PositionalArgument | OptionalArgument | BooleanArgument],
processed_args: list[PositionalArgument | OptionalArgument | BooleanArgument], *,
name: str = "Argenta",
description: str = "Argenta available arguments",
epilog: str = "github.com/koloideal/Argenta | made by kolo",
@@ -22,38 +22,18 @@ class ArgParser:
:param epilog: the epilog of the ArgParse instance
:param processed_args: registered and processed arguments
"""
self.name = name
self.description = description
self.epilog = epilog
self._name: str = name
self._description: str = description
self._epilog: str = epilog
self.entity: ArgumentParser = ArgumentParser(
prog=name, description=description, epilog=epilog
)
self.args: (
list[PositionalArgument | OptionalArgument | BooleanArgument] | None
) = processed_args
self._entity: ArgumentParser = ArgumentParser(prog=name, description=description, epilog=epilog)
self._processed_args: list[PositionalArgument | OptionalArgument | BooleanArgument] = processed_args
for arg in processed_args:
if isinstance(arg, PositionalArgument) or isinstance(arg, OptionalArgument):
_ = self._entity.add_argument(arg.string_entity)
else:
_ = self._entity.add_argument(arg.string_entity, action="store_true")
def set_args(
self, *args: PositionalArgument | OptionalArgument | BooleanArgument
) -> None:
"""
Public. Sets the arguments to be processed
:param args: processed arguments
:return: None
"""
self.args.extend(args)
def register_args(self) -> None:
"""
Private. Registers initialized command line arguments
:return: None
"""
if not self.args:
return
for arg in self.args:
if type(arg) is PositionalArgument:
self.entity.add_argument(arg.get_string_entity())
elif type(arg) is OptionalArgument:
self.entity.add_argument(arg.get_string_entity())
elif type(arg) is BooleanArgument:
self.entity.add_argument(arg.get_string_entity(), action="store_true")
def parse_args(self) -> Namespace:
return self._entity.parse_args()