From e9b53b53dfb2e76368063382f87ec7dd9e190b5e Mon Sep 17 00:00:00 2001 From: madtoinou Date: Fri, 8 Nov 2024 12:23:16 +0100 Subject: [PATCH] fix: typing imports --- darts/explainability/tft_explainer.py | 8 +------- darts/models/forecasting/arima.py | 5 +++-- darts/timeseries.py | 7 +------ 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/darts/explainability/tft_explainer.py b/darts/explainability/tft_explainer.py index 456a0b33bd..09d8c91dd2 100644 --- a/darts/explainability/tft_explainer.py +++ b/darts/explainability/tft_explainer.py @@ -23,7 +23,7 @@ """ from collections.abc import Sequence -from typing import Optional, Union +from typing import Literal, Optional, Union import matplotlib.axes import matplotlib.pyplot as plt @@ -38,12 +38,6 @@ from darts.models import TFTModel from darts.utils.utils import generate_index -try: - from typing import Literal -except ImportError: - from typing_extensions import Literal - - logger = get_logger(__name__) diff --git a/darts/models/forecasting/arima.py b/darts/models/forecasting/arima.py index a9f880aa5c..7c84c2385c 100644 --- a/darts/models/forecasting/arima.py +++ b/darts/models/forecasting/arima.py @@ -10,12 +10,13 @@ .. [1] https://wikipedia.org/wiki/Autoregressive_integrated_moving_average """ +import sys from collections.abc import Sequence from typing import Literal, Optional, Union -try: +if sys.version_info >= (3, 10): from typing import TypeAlias -except ImportError: +else: from typing_extensions import TypeAlias import numpy as np diff --git a/darts/timeseries.py b/darts/timeseries.py index c309c82d12..6f2597dd15 100644 --- a/darts/timeseries.py +++ b/darts/timeseries.py @@ -42,7 +42,7 @@ from copy import deepcopy from inspect import signature from io import StringIO -from typing import Any, Callable, Optional, Union +from typing import Any, Callable, Literal, Optional, Union import matplotlib.axes import matplotlib.pyplot as plt @@ -60,11 +60,6 @@ n_steps_between, ) -try: - from typing import Literal -except ImportError: - from typing_extensions import Literal - if sys.version_info >= (3, 11): from typing import Self else: