diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 967f461..ac5f98f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v6.0.0 hooks: - id: check-added-large-files args: ["--maxkb=1000"] @@ -24,32 +24,32 @@ repos: - id: mixed-line-ending - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.7 + rev: v0.15.10 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] types_or: [python, pyi, jupyter] - repo: https://github.com/pycqa/isort - rev: 5.13.2 + rev: 8.0.1 hooks: - id: isort name: isort - - repo: https://github.com/psf/black - rev: 24.4.2 + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 26.3.1 hooks: - id: black language_version: python3 - repo: https://github.com/asottile/blacken-docs - rev: 1.16.0 + rev: 1.20.0 hooks: - id: blacken-docs additional_dependencies: [black==22.3.0] - repo: https://github.com/pycqa/flake8 - rev: 7.0.0 + rev: 7.3.0 hooks: - id: flake8 exclude: docs/source/conf.py, __pycache__ @@ -66,7 +66,7 @@ repos: ] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.10.0 + rev: v1.20.1 hooks: - id: mypy files: predictably/ @@ -85,14 +85,14 @@ repos: additional_dependencies: [".[toml]"] - repo: https://github.com/PyCQA/bandit - rev: 1.7.8 + rev: 1.9.4 hooks: - id: bandit args: ["-c", "pyproject.toml"] additional_dependencies: ["bandit[toml]"] - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.2 hooks: - id: codespell types_or: [python, rst, markdown] @@ -100,14 +100,14 @@ repos: - tomli - repo: https://github.com/PyCQA/doc8 - rev: v1.1.1 + rev: v2.0.0 hooks: - id: doc8 args: ["--max-line-length=88", "--config=pyproject.toml", "docs"] additional_dependencies: ["tomli"] - repo: https://github.com/sphinx-contrib/sphinx-lint - rev: v0.9.1 + rev: v1.0.2 hooks: - id: sphinx-lint @@ -118,13 +118,13 @@ repos: additional_dependencies: ["flake8-builtins"] - repo: https://github.com/asottile/pyupgrade - rev: v3.15.2 + rev: v3.21.2 hooks: - id: pyupgrade args: ["--py38-plus"] - repo: https://github.com/numpy/numpydoc - rev: v1.7.0 + rev: v1.10.0 hooks: - id: numpydoc-validation exclude: | diff --git a/predictably/__init__.py b/predictably/__init__.py index 4dfd1e1..bfd42c7 100644 --- a/predictably/__init__.py +++ b/predictably/__init__.py @@ -4,6 +4,7 @@ Predictable, well-documented interfaces so you can predict *ably*. """ + from typing import List from predictably._config import ( diff --git a/predictably/_config.py b/predictably/_config.py index b157e99..7232aa9 100644 --- a/predictably/_config.py +++ b/predictably/_config.py @@ -9,6 +9,7 @@ Allows users to configure `predictably`. """ + import threading from contextlib import contextmanager from typing import Any, Dict, Iterator, List, Literal, Optional, get_args diff --git a/predictably/_config_param_setting.py b/predictably/_config_param_setting.py index 362ca35..1c5b725 100644 --- a/predictably/_config_param_setting.py +++ b/predictably/_config_param_setting.py @@ -4,6 +4,7 @@ Used to store information about predictably's global configuration. """ + import collections import warnings from dataclasses import dataclass diff --git a/predictably/_core/__init__.py b/predictably/_core/__init__.py index cdadf3d..a7de0c2 100644 --- a/predictably/_core/__init__.py +++ b/predictably/_core/__init__.py @@ -4,6 +4,7 @@ These tools can be used to build other `predictably` compliant packages. """ + from typing import List __author__: List[str] = ["RNKuhns"] diff --git a/predictably/_core/_base.py b/predictably/_core/_base.py index 9680109..3c526ab 100644 --- a/predictably/_core/_base.py +++ b/predictably/_core/_base.py @@ -7,6 +7,7 @@ `predictably` classes typically inherit from ``BaseClass``. """ + import collections import inspect import re diff --git a/predictably/_core/_pprint/__init__.py b/predictably/_core/_pprint/__init__.py index f3a5864..d3281bc 100644 --- a/predictably/_core/_pprint/__init__.py +++ b/predictably/_core/_pprint/__init__.py @@ -7,6 +7,7 @@ The approach follows scikit-learn conventions. """ + from typing import List __author__: List[str] = ["RNKuhns"] diff --git a/predictably/_core/_pprint/_object_html_repr.py b/predictably/_core/_pprint/_object_html_repr.py index f22d785..06af07e 100644 --- a/predictably/_core/_pprint/_object_html_repr.py +++ b/predictably/_core/_pprint/_object_html_repr.py @@ -6,6 +6,7 @@ Follows scikit-learn pretty printing conventions. """ + # mypy: ignore-errors from __future__ import annotations @@ -343,11 +344,7 @@ def _write_base_object_html( #$id div.sk-text-repr-fallback { display: none; } -""".replace( - " ", "" -).replace( - "\n", "" -) +""".replace(" ", "").replace("\n", "") def _object_html_repr(base_object: prc._base.BaseOBject) -> str: diff --git a/predictably/_core/_pprint/_pprint.py b/predictably/_core/_pprint/_pprint.py index 46d84ac..415f1eb 100644 --- a/predictably/_core/_pprint/_pprint.py +++ b/predictably/_core/_pprint/_pprint.py @@ -6,6 +6,7 @@ The pretty printing approach very closely follows scikit-learn. """ + # mypy: ignore-errors import inspect import pprint diff --git a/predictably/_core/tests/__init__.py b/predictably/_core/tests/__init__.py index ed10264..873d64d 100644 --- a/predictably/_core/tests/__init__.py +++ b/predictably/_core/tests/__init__.py @@ -5,6 +5,7 @@ Tests of core functionality are included here. Tests of specific submodule functionality is included in submodule tests. """ + from typing import List __all__: List[str] = [] diff --git a/predictably/_core/tests/test_config.py b/predictably/_core/tests/test_config.py index 8f63e5a..b8a12c2 100644 --- a/predictably/_core/tests/test_config.py +++ b/predictably/_core/tests/test_config.py @@ -2,6 +2,7 @@ # The code is copyrighted by the respective scikit-learn developers (BSD-3-Clause # License): https://github.com/scikit-learn/scikit-learn/blob/main/COPYING """Test configuration functionality.""" + import time from concurrent.futures import ThreadPoolExecutor from typing import Any diff --git a/predictably/_core/tests/test_exceptions.py b/predictably/_core/tests/test_exceptions.py index 4c89349..7ba43c7 100644 --- a/predictably/_core/tests/test_exceptions.py +++ b/predictably/_core/tests/test_exceptions.py @@ -6,6 +6,7 @@ test_exceptions_raise_error - Test that skbase exceptions raise expected error. """ + from typing import List import pytest diff --git a/predictably/data/__init__.py b/predictably/data/__init__.py index dec1bfe..6af5851 100644 --- a/predictably/data/__init__.py +++ b/predictably/data/__init__.py @@ -8,6 +8,7 @@ as examples throughout the package. - :mod:`predictably.data.generate` provides tools for data generation. """ + from typing import List __author__: List[str] = ["RNKuhns"] diff --git a/predictably/data/types/__init__.py b/predictably/data/types/__init__.py index 99bb5f9..f5b9fa6 100644 --- a/predictably/data/types/__init__.py +++ b/predictably/data/types/__init__.py @@ -6,6 +6,7 @@ interface or the `from_array` and `from_dataframe` interface on a particular data type class. """ + from typing import List from predictably.data.types._base import Metadata diff --git a/predictably/data/types/_base.py b/predictably/data/types/_base.py index 7b61b01..c594ad2 100644 --- a/predictably/data/types/_base.py +++ b/predictably/data/types/_base.py @@ -4,6 +4,7 @@ All `predictably` data types should inherit from ``BasePredictablyDataType``. """ + from __future__ import annotations import collections diff --git a/predictably/data/types/_cross_section.py b/predictably/data/types/_cross_section.py index 81fd370..68564c8 100644 --- a/predictably/data/types/_cross_section.py +++ b/predictably/data/types/_cross_section.py @@ -6,6 +6,7 @@ or `from_dataframe` methods or the ``predictably.from_external_data`` functional interface. """ + from __future__ import annotations import attrs diff --git a/predictably/data/types/_from_external.py b/predictably/data/types/_from_external.py index 2304c73..fb7f270 100644 --- a/predictably/data/types/_from_external.py +++ b/predictably/data/types/_from_external.py @@ -5,6 +5,7 @@ Users should use :func:`predictably.from_external_data` or call the `from_array` or `from_dataframe` on the applicable `predictably` data type. """ + from __future__ import annotations import sys diff --git a/predictably/data/types/_panel.py b/predictably/data/types/_panel.py index 534ea6a..a2dc55a 100644 --- a/predictably/data/types/_panel.py +++ b/predictably/data/types/_panel.py @@ -6,6 +6,7 @@ or `from_dataframe` methods or the ``predictably.from_external_data`` functional interface. """ + from __future__ import annotations import attrs diff --git a/predictably/data/types/_timeseries.py b/predictably/data/types/_timeseries.py index f950515..62c98b9 100644 --- a/predictably/data/types/_timeseries.py +++ b/predictably/data/types/_timeseries.py @@ -6,6 +6,7 @@ or `from_dataframe` methods or the ``predictably.from_external_data`` functional interface. """ + from __future__ import annotations import sys diff --git a/predictably/data/types/_types.py b/predictably/data/types/_types.py index 2a3579f..919259b 100644 --- a/predictably/data/types/_types.py +++ b/predictably/data/types/_types.py @@ -4,6 +4,7 @@ Should be used for typing throughout `predictably`. """ + from __future__ import annotations import sys @@ -104,7 +105,7 @@ def _get_forward_ref_module_name(fref: str, return_abbrev: bool = False) -> str: def _evaluate_available_forward_refs( - supported: tuple[str | type, ...] + supported: tuple[str | type, ...], ) -> tuple[tuple[type, ...], tuple[str, ...]]: """Load and evaluate available forward references. @@ -152,7 +153,7 @@ def _evaluate_available_forward_refs( def _supported_type_msg( - type_: Literal["dataframe", "array", "any"] = "dataframe" + type_: Literal["dataframe", "array", "any"] = "dataframe", ) -> str: """Create message about the types of dataframes that `predictably` supports. @@ -185,7 +186,7 @@ def _supported_type_msg( def raise_not_supported_external_type( - type_: Literal["dataframe", "array", "any"] = "dataframe" + type_: Literal["dataframe", "array", "any"] = "dataframe", ) -> NoReturn: """Raise an error if the input data container is not supported by `predictably`. diff --git a/predictably/data/types/tests/__init__.py b/predictably/data/types/tests/__init__.py index 319639c..4efdbe1 100644 --- a/predictably/data/types/tests/__init__.py +++ b/predictably/data/types/tests/__init__.py @@ -4,6 +4,7 @@ Tests for all data type functionality are included here. """ + from typing import List __all__: List[str] = [] diff --git a/predictably/data/types/tests/test_base_types.py b/predictably/data/types/tests/test_base_types.py index 5372374..5282ce0 100644 --- a/predictably/data/types/tests/test_base_types.py +++ b/predictably/data/types/tests/test_base_types.py @@ -4,6 +4,7 @@ Tests for all data type functionality are included here. """ + import re from typing import List diff --git a/predictably/tests/__init__.py b/predictably/tests/__init__.py index ed10264..873d64d 100644 --- a/predictably/tests/__init__.py +++ b/predictably/tests/__init__.py @@ -5,6 +5,7 @@ Tests of core functionality are included here. Tests of specific submodule functionality is included in submodule tests. """ + from typing import List __all__: List[str] = [] diff --git a/predictably/tests/test_config.py b/predictably/tests/test_config.py index 8f63e5a..b8a12c2 100644 --- a/predictably/tests/test_config.py +++ b/predictably/tests/test_config.py @@ -2,6 +2,7 @@ # The code is copyrighted by the respective scikit-learn developers (BSD-3-Clause # License): https://github.com/scikit-learn/scikit-learn/blob/main/COPYING """Test configuration functionality.""" + import time from concurrent.futures import ThreadPoolExecutor from typing import Any diff --git a/predictably/utils/__init__.py b/predictably/utils/__init__.py index 013de33..70f956a 100644 --- a/predictably/utils/__init__.py +++ b/predictably/utils/__init__.py @@ -8,6 +8,7 @@ This module includes general utilities. Statistical utilities will be kept in predictably.stats.utils. """ + from typing import List __author__: List[str] = ["RNKuhns"] diff --git a/predictably/utils/_iter.py b/predictably/utils/_iter.py index f95d8ee..2dcfd95 100644 --- a/predictably/utils/_iter.py +++ b/predictably/utils/_iter.py @@ -4,6 +4,7 @@ # are copyrighted by the skbase developers, BSD-3-Clause License. For # conditions see https://github.com/sktime/skbase/blob/main/LICENSE """Utility functionality for working with sequences.""" # numpydoc ignore=ES01 + import collections import re from typing import Any, List, Optional, Sequence, Union diff --git a/predictably/utils/tests/test_iter.py b/predictably/utils/tests/test_iter.py index ca32992..c84b60e 100644 --- a/predictably/utils/tests/test_iter.py +++ b/predictably/utils/tests/test_iter.py @@ -16,6 +16,7 @@ - test_scalar_to_seq_raises: verify that _scalar_to_seq raises error when an invalid value is provided for sequence_type parameter. """ + from collections.abc import Sequence import pytest diff --git a/predictably/validate/__init__.py b/predictably/validate/__init__.py index e843452..4fc6286 100644 --- a/predictably/validate/__init__.py +++ b/predictably/validate/__init__.py @@ -8,6 +8,7 @@ This module contains functions used throughout `predictably` to provide standard validation of inputs to `predictably` methods and functions. """ + from typing import List from predictably.validate._named_objects import ( diff --git a/predictably/validate/_named_objects.py b/predictably/validate/_named_objects.py index 3a47907..06f72ec 100644 --- a/predictably/validate/_named_objects.py +++ b/predictably/validate/_named_objects.py @@ -9,6 +9,7 @@ named objects conform with predictably's named object API. Among other use cases this is used in particular to verify that input to pipelines are specified correctly. """ + import collections.abc from typing import ( TYPE_CHECKING, diff --git a/predictably/validate/_types.py b/predictably/validate/_types.py index 18a521c..8ee4518 100644 --- a/predictably/validate/_types.py +++ b/predictably/validate/_types.py @@ -8,6 +8,7 @@ For specific functionality to validate the `predictably` data types, see :mod:`predictably.validate._data_types`. """ + import collections import inspect import math diff --git a/predictably/validate/tests/test_type_validations.py b/predictably/validate/tests/test_type_validations.py index 80a525f..0520a17 100644 --- a/predictably/validate/tests/test_type_validations.py +++ b/predictably/validate/tests/test_type_validations.py @@ -16,6 +16,7 @@ - test_check_sequence_with_seq_of_class_and_instance_input - test_convert_scalar_seq_type_input_to_tuple_raises_error """ + import collections # import numpy as np