From e3bdad36cc3a1a00c1e6772ca1c1898085ab73e0 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 5 Jan 2023 11:38:34 +0100 Subject: Adding upstream version 3.0.0~a1. Signed-off-by: Daniel Baumann --- pendulum/tz/exceptions.py | 55 +++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 23 deletions(-) (limited to 'pendulum/tz/exceptions.py') diff --git a/pendulum/tz/exceptions.py b/pendulum/tz/exceptions.py index d1572f9..b8833ac 100644 --- a/pendulum/tz/exceptions.py +++ b/pendulum/tz/exceptions.py @@ -1,23 +1,32 @@ -class TimezoneError(ValueError): - - pass - - -class NonExistingTime(TimezoneError): - - message = "The datetime {} does not exist." - - def __init__(self, dt): - message = self.message.format(dt) - - super(NonExistingTime, self).__init__(message) - - -class AmbiguousTime(TimezoneError): - - message = "The datetime {} is ambiguous." - - def __init__(self, dt): - message = self.message.format(dt) - - super(AmbiguousTime, self).__init__(message) +from __future__ import annotations + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from datetime import datetime + + +class TimezoneError(ValueError): + pass + + +class InvalidTimezone(TimezoneError): + pass + + +class NonExistingTime(TimezoneError): + message = "The datetime {} does not exist." + + def __init__(self, dt: datetime) -> None: + message = self.message.format(dt) + + super().__init__(message) + + +class AmbiguousTime(TimezoneError): + message = "The datetime {} is ambiguous." + + def __init__(self, dt: datetime) -> None: + message = self.message.format(dt) + + super().__init__(message) -- cgit v1.2.3