From fe5ea78aafd8664ce31853d4945b9fae789ac2a9 Mon Sep 17 00:00:00 2001 From: CelestinoXP Date: Sat, 20 Jul 2024 19:59:16 +0100 Subject: [PATCH] [MNT] Update Callable import from typing to collections.abc As per official documentation (https://docs.python.org/3.9/library/typing.html#typing.Callable), typing.Callable is deprecated in favour of collections.abc.Callable. This PR makes the corresponding changes in the imports --- pycaret/anomaly/functional.py | 9 ++++++++- pycaret/classification/functional.py | 9 ++++++++- pycaret/classification/oop.py | 9 ++++++++- pycaret/clustering/functional.py | 9 ++++++++- pycaret/containers/metrics/base_metric.py | 4 ++++ pycaret/containers/metrics/clustering.py | 3 +++ pycaret/internal/logging.py | 6 +++++- pycaret/internal/metrics.py | 8 +++++++- pycaret/internal/patches/sklearn.py | 9 ++++++++- .../pycaret_experiment/pycaret_experiment.py | 9 ++++++++- .../supervised_experiment.py | 9 ++++++++- .../unsupervised_experiment.py | 9 ++++++++- pycaret/parallel/fugue_backend.py | 8 +++++++- pycaret/regression/functional.py | 9 ++++++++- pycaret/regression/oop.py | 9 ++++++++- pycaret/time_series/forecasting/functional.py | 19 ++++++++----------- pycaret/time_series/forecasting/oop.py | 9 ++++++++- pycaret/utils/generic.py | 10 ++++++++-- 18 files changed, 130 insertions(+), 27 deletions(-) diff --git a/pycaret/anomaly/functional.py b/pycaret/anomaly/functional.py index d76fb7648..5d13f1945 100644 --- a/pycaret/anomaly/functional.py +++ b/pycaret/anomaly/functional.py @@ -1,6 +1,13 @@ +# Copyright (C) 2019-2024 PyCaret +# Author: Moez Ali (moez.ali@queensu.ca) +# Contributors (https://github.com/pycaret/pycaret/graphs/contributors) +# License: MIT + + import logging import os -from typing import Any, BinaryIO, Callable, Dict, List, Optional, Union +from collections.abc import Callable +from typing import Any, BinaryIO, Dict, List, Optional, Union import pandas as pd from joblib.memory import Memory diff --git a/pycaret/classification/functional.py b/pycaret/classification/functional.py index 1e439c859..e32317fcd 100644 --- a/pycaret/classification/functional.py +++ b/pycaret/classification/functional.py @@ -1,6 +1,13 @@ +# Copyright (C) 2019-2024 PyCaret +# Author: Moez Ali (moez.ali@queensu.ca) +# Contributors (https://github.com/pycaret/pycaret/graphs/contributors) +# License: MIT + + import logging import os -from typing import Any, BinaryIO, Callable, Dict, List, Optional, Union +from collections.abc import Callable +from typing import Any, BinaryIO, Dict, List, Optional, Union import pandas as pd from joblib.memory import Memory diff --git a/pycaret/classification/oop.py b/pycaret/classification/oop.py index 2d56073ab..d9d9d0b41 100644 --- a/pycaret/classification/oop.py +++ b/pycaret/classification/oop.py @@ -1,9 +1,16 @@ +# Copyright (C) 2019-2024 PyCaret +# Author: Moez Ali (moez.ali@queensu.ca) +# Contributors (https://github.com/pycaret/pycaret/graphs/contributors) +# License: MIT + + import datetime import gc import logging import re import time -from typing import Any, Callable, Dict, List, Optional, Tuple, Union +from collections.abc import Callable +from typing import Any, Dict, List, Optional, Tuple, Union from unittest.mock import patch import numpy as np # type: ignore diff --git a/pycaret/clustering/functional.py b/pycaret/clustering/functional.py index 61567145e..037342176 100644 --- a/pycaret/clustering/functional.py +++ b/pycaret/clustering/functional.py @@ -1,6 +1,13 @@ +# Copyright (C) 2019-2024 PyCaret +# Author: Moez Ali (moez.ali@queensu.ca) +# Contributors (https://github.com/pycaret/pycaret/graphs/contributors) +# License: MIT + + import logging import os -from typing import Any, BinaryIO, Callable, Dict, List, Optional, Union +from collections.abc import Callable +from typing import Any, BinaryIO, Dict, List, Optional, Union import pandas as pd from joblib.memory import Memory diff --git a/pycaret/containers/metrics/base_metric.py b/pycaret/containers/metrics/base_metric.py index 44f297be0..5a2334f96 100644 --- a/pycaret/containers/metrics/base_metric.py +++ b/pycaret/containers/metrics/base_metric.py @@ -1,7 +1,11 @@ +# Copyright (C) 2019-2024 PyCaret + # Module: containers.metrics.base_metric # Author: Antoni Baum (Yard1) +# Contributors (https://github.com/pycaret/pycaret/graphs/contributors) # License: MIT + from typing import Any, Dict, Optional, Union from sklearn.metrics import make_scorer # type: ignore diff --git a/pycaret/containers/metrics/clustering.py b/pycaret/containers/metrics/clustering.py index 8e4d30ce5..48d1bfde7 100644 --- a/pycaret/containers/metrics/clustering.py +++ b/pycaret/containers/metrics/clustering.py @@ -1,5 +1,8 @@ +# Copyright (C) 2019-2024 PyCaret + # Module: containers.metrics.clustering # Author: Antoni Baum (Yard1) +# Contributors (https://github.com/pycaret/pycaret/graphs/contributors) # License: MIT # The purpose of this module is to serve as a central repository of clustering metrics. The `clustering` module will diff --git a/pycaret/internal/logging.py b/pycaret/internal/logging.py index de268f954..0dea5ff21 100644 --- a/pycaret/internal/logging.py +++ b/pycaret/internal/logging.py @@ -1,13 +1,17 @@ +# Copyright (C) 2019-2024 PyCaret + # Module: internal.logging # Author: Antoni Baum (Yard1) +# Contributors (https://github.com/pycaret/pycaret/graphs/contributors) # License: MIT import logging import os import traceback import warnings +from collections.abc import Callable from contextlib import redirect_stderr, redirect_stdout -from typing import Callable, Optional, Union +from typing import Optional, Union try: from wurlitzer import pipes diff --git a/pycaret/internal/metrics.py b/pycaret/internal/metrics.py index 03b555219..e743e9a7c 100644 --- a/pycaret/internal/metrics.py +++ b/pycaret/internal/metrics.py @@ -1,6 +1,12 @@ +# Copyright (C) 2019-2024 PyCaret +# Author: Moez Ali (moez.ali@queensu.ca) +# Contributors (https://github.com/pycaret/pycaret/graphs/contributors) +# License: MIT + + import traceback import warnings -from typing import Callable +from collections.abc import Callable import numpy as np from sklearn.exceptions import FitFailedWarning diff --git a/pycaret/internal/patches/sklearn.py b/pycaret/internal/patches/sklearn.py index 34eac9afd..38ebe22ca 100644 --- a/pycaret/internal/patches/sklearn.py +++ b/pycaret/internal/patches/sklearn.py @@ -1,4 +1,11 @@ -from typing import Any, Callable +# Copyright (C) 2019-2024 PyCaret +# Author: Moez Ali (moez.ali@queensu.ca) +# Contributors (https://github.com/pycaret/pycaret/graphs/contributors) +# License: MIT + + +from collections.abc import Callable +from typing import Any from unittest.mock import patch import numpy as np diff --git a/pycaret/internal/pycaret_experiment/pycaret_experiment.py b/pycaret/internal/pycaret_experiment/pycaret_experiment.py index cb737ea91..5f8eeb664 100644 --- a/pycaret/internal/pycaret_experiment/pycaret_experiment.py +++ b/pycaret/internal/pycaret_experiment/pycaret_experiment.py @@ -1,8 +1,15 @@ +# Copyright (C) 2019-2024 PyCaret +# Author: Moez Ali (moez.ali@queensu.ca) +# Contributors (https://github.com/pycaret/pycaret/graphs/contributors) +# License: MIT + + import inspect import os import warnings from collections import defaultdict -from typing import Any, BinaryIO, Callable, Dict, Optional, Union +from collections.abc import Callable +from typing import Any, BinaryIO, Dict, Optional, Union import cloudpickle import pandas as pd diff --git a/pycaret/internal/pycaret_experiment/supervised_experiment.py b/pycaret/internal/pycaret_experiment/supervised_experiment.py index 631e2223b..ad2d53a88 100644 --- a/pycaret/internal/pycaret_experiment/supervised_experiment.py +++ b/pycaret/internal/pycaret_experiment/supervised_experiment.py @@ -1,3 +1,9 @@ +# Copyright (C) 2019-2024 PyCaret +# Author: Moez Ali (moez.ali@queensu.ca) +# Contributors (https://github.com/pycaret/pycaret/graphs/contributors) +# License: MIT + + import datetime import gc import os @@ -5,9 +11,10 @@ import traceback import warnings from abc import abstractmethod +from collections.abc import Callable from copy import copy, deepcopy from functools import partial -from typing import Any, BinaryIO, Callable, Dict, List, Optional, Set, Tuple, Union +from typing import Any, BinaryIO, Dict, List, Optional, Set, Tuple, Union from unittest.mock import patch import matplotlib.pyplot as plt diff --git a/pycaret/internal/pycaret_experiment/unsupervised_experiment.py b/pycaret/internal/pycaret_experiment/unsupervised_experiment.py index 73d59ee5a..fc09f0c59 100644 --- a/pycaret/internal/pycaret_experiment/unsupervised_experiment.py +++ b/pycaret/internal/pycaret_experiment/unsupervised_experiment.py @@ -1,9 +1,16 @@ +# Copyright (C) 2019-2024 PyCaret +# Author: Moez Ali (moez.ali@queensu.ca) +# Contributors (https://github.com/pycaret/pycaret/graphs/contributors) +# License: MIT + + import datetime import gc import logging import time import traceback -from typing import Any, Callable, Dict, List, Optional, Union +from collections.abc import Callable +from typing import Any, Dict, List, Optional, Union import numpy as np # type: ignore import pandas as pd diff --git a/pycaret/parallel/fugue_backend.py b/pycaret/parallel/fugue_backend.py index ca353c9f4..9d7d17655 100644 --- a/pycaret/parallel/fugue_backend.py +++ b/pycaret/parallel/fugue_backend.py @@ -1,7 +1,13 @@ +# Copyright (C) 2019-2024 PyCaret +# Author: Moez Ali (moez.ali@queensu.ca) +# Contributors (https://github.com/pycaret/pycaret/graphs/contributors) +# License: MIT + import random +from collections.abc import Callable from math import ceil from threading import RLock -from typing import Any, Callable, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, Union import cloudpickle import pandas as pd diff --git a/pycaret/regression/functional.py b/pycaret/regression/functional.py index 10454d21a..83cc86c1c 100644 --- a/pycaret/regression/functional.py +++ b/pycaret/regression/functional.py @@ -1,6 +1,13 @@ +# Copyright (C) 2019-2024 PyCaret +# Author: Moez Ali (moez.ali@queensu.ca) +# Contributors (https://github.com/pycaret/pycaret/graphs/contributors) +# License: MIT + + import logging import os -from typing import Any, BinaryIO, Callable, Dict, List, Optional, Union +from collections.abc import Callable +from typing import Any, BinaryIO, Dict, List, Optional, Union import pandas as pd from joblib.memory import Memory diff --git a/pycaret/regression/oop.py b/pycaret/regression/oop.py index 249341b58..f47739bd6 100644 --- a/pycaret/regression/oop.py +++ b/pycaret/regression/oop.py @@ -1,7 +1,14 @@ +# Copyright (C) 2019-2024 PyCaret +# Author: Moez Ali (moez.ali@queensu.ca) +# Contributors (https://github.com/pycaret/pycaret/graphs/contributors) +# License: MIT + + import logging import re import time -from typing import Any, Callable, Dict, List, Optional, Tuple, Union +from collections.abc import Callable +from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np # type: ignore import pandas as pd diff --git a/pycaret/time_series/forecasting/functional.py b/pycaret/time_series/forecasting/functional.py index 5ffcfbcda..296d51bad 100644 --- a/pycaret/time_series/forecasting/functional.py +++ b/pycaret/time_series/forecasting/functional.py @@ -1,19 +1,16 @@ +# Copyright (C) 2019-2024 PyCaret +# Author: Moez Ali (moez.ali@queensu.ca) +# Contributors (https://github.com/pycaret/pycaret/graphs/contributors) +# License: MIT + + """Functional API for Time Series Forecasting Experiment """ import logging import os -from typing import ( - TYPE_CHECKING, - Any, - BinaryIO, - Callable, - Dict, - List, - Optional, - Tuple, - Union, -) +from collections.abc import Callable +from typing import TYPE_CHECKING, Any, BinaryIO, Dict, List, Optional, Tuple, Union import numpy as np import pandas as pd diff --git a/pycaret/time_series/forecasting/oop.py b/pycaret/time_series/forecasting/oop.py index 6f44508a7..6ea3a9303 100644 --- a/pycaret/time_series/forecasting/oop.py +++ b/pycaret/time_series/forecasting/oop.py @@ -1,3 +1,9 @@ +# Copyright (C) 2019-2024 PyCaret +# Author: Moez Ali (moez.ali@queensu.ca) +# Contributors (https://github.com/pycaret/pycaret/graphs/contributors) +# License: MIT + + import datetime import gc import logging @@ -6,8 +12,9 @@ import traceback import warnings from collections import defaultdict +from collections.abc import Callable from copy import deepcopy -from typing import Any, Callable, Dict, List, Optional, Tuple, Union +from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np import pandas as pd diff --git a/pycaret/utils/generic.py b/pycaret/utils/generic.py index db2b98e6f..53f25c5d6 100644 --- a/pycaret/utils/generic.py +++ b/pycaret/utils/generic.py @@ -1,11 +1,17 @@ +# Copyright (C) 2019-2024 PyCaret +# Author: Moez Ali (moez.ali@queensu.ca) +# Contributors (https://github.com/pycaret/pycaret/graphs/contributors) +# License: MIT + + import functools import inspect import traceback import warnings -from collections.abc import Mapping +from collections.abc import Callable, Mapping from copy import deepcopy from enum import Enum, auto -from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Set, Tuple, Union +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set, Tuple, Union import numpy as np import pandas as pd