Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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"]
Expand All @@ -24,32 +24,32 @@ repos:
- id: mixed-line-ending

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.7
rev: v0.16.1
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: 9.0.0b1
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.5.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__
Expand All @@ -66,7 +66,7 @@ repos:
]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
rev: v2.3.0
hooks:
- id: mypy
files: predictably/
Expand All @@ -85,29 +85,29 @@ 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.3
hooks:
- id: codespell
types_or: [python, rst, markdown]
additional_dependencies:
- 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

Expand All @@ -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.11.0rc0
hooks:
- id: numpydoc-validation
exclude: |
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def find_source(): # numpydoc ignore=RT01
},
{
"name": "Slack",
"url": f"https://join.slack.com/t/{org}/shared_invite/zt-21ezi33ip-WGJCUBCWc5yVrr6FOsARaw", # noqa: E501
"url": f"https://join.slack.com/t/{org}/shared_invite/zt-21ezi33ip-WGJCUBCWc5yVrr6FOsARaw",
"icon": "fab fa-slack",
},
{
Expand Down
7 changes: 4 additions & 3 deletions predictably/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

Predictable, well-documented interfaces so you can predict *ably*.
"""

from typing import List

from predictably._config import (
Expand All @@ -18,9 +19,9 @@

__author__: List[str] = ["RNKuhns"]
__all__: List[str] = [
"get_default_config",
"config_context",
"get_config",
"set_config",
"get_default_config",
"reset_config",
"config_context",
"set_config",
]
10 changes: 4 additions & 6 deletions predictably/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,11 +18,11 @@

__author__: List[str] = ["RNKuhns"]
__all__: List[str] = [
"get_default_config",
"config_context",
"get_config",
"set_config",
"get_default_config",
"reset_config",
"config_context",
"set_config",
]


Expand Down Expand Up @@ -271,8 +272,6 @@ def _update_local_config(
if not local_threadsafe:
global_config.update(local_config)

return None


def reset_config() -> None:
"""Reset the global configuration to the default.
Expand Down Expand Up @@ -314,7 +313,6 @@ def reset_config() -> None:
"""
default_config = get_default_config()
set_config(**default_config)
return None


@contextmanager
Expand Down
9 changes: 6 additions & 3 deletions predictably/_config_param_setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

Used to store information about predictably's global configuration.
"""

import collections
import warnings
from dataclasses import dataclass
Expand Down Expand Up @@ -95,9 +96,11 @@ def is_valid_param_value(self, value: Any) -> bool:
Whether a parameter value is valid.
"""
valid_param: bool
if not isinstance(value, self.expected_type):
valid_param = False
elif self.allowed_values is not None and value not in self.get_allowed_values():
if (
not isinstance(value, self.expected_type)
or self.allowed_values is not None
and value not in self.get_allowed_values()
):
valid_param = False
else:
valid_param = True
Expand Down
1 change: 1 addition & 0 deletions predictably/_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

These tools can be used to build other `predictably` compliant packages.
"""

from typing import List

__author__: List[str] = ["RNKuhns"]
Expand Down
1 change: 1 addition & 0 deletions predictably/_core/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

`predictably` classes typically inherit from ``BaseClass``.
"""

import collections
import inspect
import re
Expand Down
2 changes: 0 additions & 2 deletions predictably/_core/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class ForwardRefError(TypeError):
reference annotations within a function and it is not possible to do so.
"""

pass


class NotFittedError(ValueError, AttributeError):
"""Exception class to raise if estimator is used before fitting.
Expand Down
1 change: 1 addition & 0 deletions predictably/_core/_pprint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

The approach follows scikit-learn conventions.
"""

from typing import List

__author__: List[str] = ["RNKuhns"]
Expand Down
7 changes: 2 additions & 5 deletions predictably/_core/_pprint/_object_html_repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

Follows scikit-learn pretty printing conventions.
"""

# mypy: ignore-errors
from __future__ import annotations

Expand Down Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions predictably/_core/_pprint/_pprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

The pretty printing approach very closely follows scikit-learn.
"""

# mypy: ignore-errors
import inspect
import pprint
Expand All @@ -27,8 +28,6 @@ def __repr__(self):
class KeyValTupleParam(KeyValTuple):
"""Dummy class for correctly rendering key-value tuples from parameters."""

pass


def _changed_params(base_object):
"""Return dict (param_name: value) of parameters with non-default values."""
Expand Down Expand Up @@ -131,7 +130,7 @@ def __init__(
# (they are treated as dicts)
self.n_max_elements_to_show = n_max_elements_to_show

def format(self, obj, context, maxlevels, level): # noqa: A003
def format(self, obj, context, maxlevels, level):
return _safe_repr(
obj, context, maxlevels, level, changed_only=self.changed_only
)
Expand Down
1 change: 1 addition & 0 deletions predictably/_core/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []
Expand Down
1 change: 1 addition & 0 deletions predictably/_core/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions predictably/_core/tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

test_exceptions_raise_error - Test that skbase exceptions raise expected error.
"""

from typing import List

import pytest
Expand Down
1 change: 1 addition & 0 deletions predictably/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
1 change: 1 addition & 0 deletions predictably/data/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions predictably/data/types/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

All `predictably` data types should inherit from ``BasePredictablyDataType``.
"""

from __future__ import annotations

import collections
Expand Down
1 change: 1 addition & 0 deletions predictably/data/types/_cross_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
or `from_dataframe` methods or the ``predictably.from_external_data`` functional
interface.
"""

from __future__ import annotations

import attrs
Expand Down
1 change: 1 addition & 0 deletions predictably/data/types/_from_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions predictably/data/types/_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
or `from_dataframe` methods or the ``predictably.from_external_data`` functional
interface.
"""

from __future__ import annotations

import attrs
Expand Down
1 change: 1 addition & 0 deletions predictably/data/types/_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
or `from_dataframe` methods or the ``predictably.from_external_data`` functional
interface.
"""

from __future__ import annotations

import sys
Expand Down
7 changes: 4 additions & 3 deletions predictably/data/types/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

Should be used for typing throughout `predictably`.
"""

from __future__ import annotations

import sys
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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`.

Expand Down
Loading
Loading