Skip to content

Commit

Permalink
lint: since we moved to python 3.9, let's bump ruff's target to 3.9, too
Browse files Browse the repository at this point in the history
  • Loading branch information
muxator committed Feb 24, 2024
1 parent dc4694c commit 156f5d2
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
# Whether to enable preview mode. When preview mode is enabled, Ruff will use unstable rules and fixes.
preview = true

# Assume Python 3.8
target-version = "py38"
# Assume Python 3.9
target-version = "py39"

[per-file-ignores]
"examples/docker-sir.py" = ["INP001", "T201"]
Expand Down
3 changes: 2 additions & 1 deletion black_it/calibrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import time
import warnings
from pathlib import Path
from typing import TYPE_CHECKING, Callable, Sequence, cast
from typing import TYPE_CHECKING, Callable, cast

import numpy as np
from joblib import Parallel, delayed # type: ignore[import]
Expand All @@ -39,6 +39,7 @@

if TYPE_CHECKING:
import os
from collections.abc import Sequence

from numpy.typing import NDArray

Expand Down
5 changes: 4 additions & 1 deletion black_it/loss_functions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@
from __future__ import annotations

from abc import ABC, abstractmethod
from typing import Callable, Optional, Sequence
from typing import TYPE_CHECKING, Callable, Optional

import numpy as np
from numpy.typing import NDArray

from black_it.utils.base import _assert

if TYPE_CHECKING:
from collections.abc import Sequence

TimeSeriesFilter = Optional[Callable[[NDArray[np.float64]], NDArray[np.float64]]]
"""A filter that receives a time series and returns its filtered version. Used by the BaseLoss constructor."""

Expand Down
3 changes: 2 additions & 1 deletion black_it/plot/plot_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import pickle # nosec B403
from pathlib import Path
from typing import TYPE_CHECKING, Collection
from typing import TYPE_CHECKING

import matplotlib.pyplot as plt # type: ignore[import]
import numpy as np
Expand All @@ -31,6 +31,7 @@

if TYPE_CHECKING:
import os
from collections.abc import Collection


def _get_samplers_id_table(saving_folder: str | os.PathLike) -> dict[str, int]:
Expand Down
4 changes: 3 additions & 1 deletion black_it/samplers/halton.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@
from __future__ import annotations

import itertools
from typing import TYPE_CHECKING, Iterator
from typing import TYPE_CHECKING

import numpy as np

from black_it.samplers.base import BaseSampler
from black_it.utils.base import check_arg, digitize_data

if TYPE_CHECKING:
from collections.abc import Iterator

from numpy.typing import NDArray

from black_it.search_space import SearchSpace
Expand Down
4 changes: 3 additions & 1 deletion black_it/schedulers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@

import contextlib
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Generator, Sequence
from typing import TYPE_CHECKING

from black_it.utils.seedable import BaseSeedable

if TYPE_CHECKING:
from collections.abc import Generator, Sequence

import numpy as np
from numpy.typing import NDArray

Expand Down
5 changes: 3 additions & 2 deletions black_it/schedulers/rl/rl_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from __future__ import annotations

import threading
from typing import TYPE_CHECKING, List, Sequence, cast
from typing import TYPE_CHECKING, cast

import numpy as np

Expand All @@ -27,6 +27,7 @@
from black_it.schedulers.base import BaseScheduler

if TYPE_CHECKING:
from collections.abc import Sequence
from queue import Queue

from numpy._typing import NDArray
Expand Down Expand Up @@ -103,7 +104,7 @@ def _add_or_get_bootstrap_sampler(
return samplers, sampler_types[HaltonSampler]

new_sampler = HaltonSampler(batch_size=1)
return tuple(list(samplers) + cast(List[BaseSampler], [new_sampler])), len(
return tuple(list(samplers) + cast(list[BaseSampler], [new_sampler])), len(
samplers,
)

Expand Down
4 changes: 3 additions & 1 deletion black_it/utils/json_pandas_checkpointing.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import json
import pickle # nosec B403
from pathlib import Path
from typing import TYPE_CHECKING, Mapping
from typing import TYPE_CHECKING

import numpy as np
import pandas as pd # type: ignore[import]
Expand All @@ -29,6 +29,8 @@
from black_it.utils.base import NumpyArrayEncoder, PathLike

if TYPE_CHECKING:
from collections.abc import Mapping

from numpy.typing import NDArray

from black_it.loss_functions.base import BaseLoss
Expand Down
4 changes: 3 additions & 1 deletion black_it/utils/sqlite3_checkpointing.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
import pickle # nosec B403
import sqlite3
from pathlib import Path
from typing import TYPE_CHECKING, Mapping, Sequence
from typing import TYPE_CHECKING

import numpy as np
from numpy.typing import NDArray

if TYPE_CHECKING:
from collections.abc import Mapping, Sequence

from black_it.loss_functions.base import BaseLoss
from black_it.samplers.base import BaseSampler
from black_it.utils.base import PathLike
Expand Down
4 changes: 3 additions & 1 deletion examples/models/economics/brock_hommes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
"""Implementation of the model in (Brock and Hommes, 1998)."""
from __future__ import annotations

from typing import TYPE_CHECKING, Sequence
from typing import TYPE_CHECKING

import numpy as np
from scipy.special import softmax

if TYPE_CHECKING:
from collections.abc import Sequence

from numpy.typing import NDArray


Expand Down
4 changes: 3 additions & 1 deletion examples/models/simple_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
"""
from __future__ import annotations

from typing import TYPE_CHECKING, Sequence
from typing import TYPE_CHECKING

import numpy as np
from scipy.stats import alpha, bernoulli

if TYPE_CHECKING:
from collections.abc import Sequence

from numpy.typing import NDArray


Expand Down
2 changes: 1 addition & 1 deletion tests/test_examples/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

"""Base module for example tests."""
import sys
from collections.abc import Sequence
from pathlib import Path
from typing import Sequence

import pytest

Expand Down
5 changes: 4 additions & 1 deletion tests/test_plot/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
import logging
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Any, Callable, Sequence
from typing import TYPE_CHECKING, Any, Callable

import matplotlib.pyplot as plt # type: ignore[import]
from matplotlib.testing.compare import compare_images # type: ignore[import]

if TYPE_CHECKING:
from collections.abc import Sequence


class BasePlotTest:
"""Base test class for plotting functions."""
Expand Down
5 changes: 4 additions & 1 deletion tests/test_plot/test_plot_descriptive_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"""This test module contains tests for the plot_descriptive_statistics.py module."""
from __future__ import annotations

from typing import Any, Sequence
from typing import TYPE_CHECKING, Any

import numpy as np

Expand All @@ -26,6 +26,9 @@
from tests.test_plot.base import BasePlotTest
from tests.utils.base import skip_on_windows

if TYPE_CHECKING:
from collections.abc import Sequence


@skip_on_windows()
class TestTsStats(BasePlotTest):
Expand Down

0 comments on commit 156f5d2

Please sign in to comment.