From d87065a1410893e7a51f2e87ad83a974e40c043b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Marschollek?= Date: Sat, 27 Nov 2021 17:04:45 +0100 Subject: [PATCH] Fix earliest_day parameter Fixes a bug where we're trying to work with an earliest day that might be None. Fixes: #1 --- impf.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/impf.py b/impf.py index 336132f..5c2d8b2 100644 --- a/impf.py +++ b/impf.py @@ -254,9 +254,9 @@ def find(self, earliest_day: Optional[str] = None, *, book: bool = False) -> boo True if the booking was successful or an appointment was found and no booking requested. """ if earliest_day is None: - earliest_day = date.today().isoformat() + earliest_day = date.today() - appt = self._find_appointment(earliest_day) + appt = self._find_appointment(earliest_day.isoformat()) if appt is None: logging.info("No appointment available") return False @@ -380,12 +380,10 @@ def main(): ): with attempt: logging.debug("Trying to find appointment (attempt %d)", i) - if not checker.find( - earliest_day=args.earliest_day.isoformat(), book=args.book - ): + if not checker.find(earliest_day=args.earliest_day, book=args.book): raise Exception("Unsuccessful attempt") else: - checker.find(earliest_day=args.earliest_day.isoformat(), book=args.book) + checker.find(earliest_day=args.earliest_day, book=args.book) if args.book: checker.print_appointments()