Refactor code for API (#3)
All checks were successful
continuous-integration/drone/push Build is passing

Co-authored-by: Mikael CAPELLE <mikael.capelle@thalesaleniaspace.com>
Co-authored-by: Mikaël Capelle <capelle.mikael@gmail.com>
Reviewed-on: #3
This commit is contained in:
2024-12-08 13:06:41 +00:00
parent 1caf93b38b
commit 87936d6422
130 changed files with 4599 additions and 3336 deletions

34
src/holt59/aoc/base.py Normal file
View File

@@ -0,0 +1,34 @@
from abc import abstractmethod
from logging import Logger
from typing import Any, Final, Iterable, Iterator, Protocol, Sequence, TypeVar, overload
_T = TypeVar("_T")
class ProgressHandler(Protocol):
@overload
def wrap(self, values: Sequence[_T]) -> Iterator[_T]: ...
@overload
def wrap(self, values: Iterable[_T], total: int) -> Iterator[_T]: ...
class BaseSolver:
def __init__(
self,
logger: Logger,
verbose: bool,
year: int,
day: int,
progress: ProgressHandler,
outputs: bool = False,
):
self.logger: Final = logger
self.verbose: Final = verbose
self.year: Final = year
self.day: Final = day
self.progress: Final = progress
self.outputs = outputs
@abstractmethod
def solve(self, input: str) -> Iterator[Any] | None: ...