Skip to content

Commit 554a754

Browse files
author
muxator
committed
lint: since we moved to python 3.9, let's bump ruff's target to 3.9, too
1 parent c8adb67 commit 554a754

File tree

14 files changed

+40
-16
lines changed

14 files changed

+40
-16
lines changed

.ruff.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
4242
# Whether to enable preview mode. When preview mode is enabled, Ruff will use unstable rules and fixes.
4343
preview = true
4444

45-
# Assume Python 3.8
46-
target-version = "py38"
45+
# Assume Python 3.9
46+
target-version = "py39"
4747

4848
[per-file-ignores]
4949
"examples/docker-sir.py" = ["INP001", "T201"]

black_it/calibrator.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import time
2323
import warnings
2424
from pathlib import Path
25-
from typing import TYPE_CHECKING, Callable, Sequence, cast
25+
from typing import TYPE_CHECKING, Callable, cast
2626

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

4040
if TYPE_CHECKING:
4141
import os
42+
from collections.abc import Sequence
4243

4344
from numpy.typing import NDArray
4445

black_it/loss_functions/base.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818
from __future__ import annotations
1919

2020
from abc import ABC, abstractmethod
21-
from typing import Callable, Optional, Sequence
21+
from typing import TYPE_CHECKING, Callable, Optional
2222

2323
import numpy as np
2424
from numpy.typing import NDArray
2525

2626
from black_it.utils.base import _assert
2727

28+
if TYPE_CHECKING:
29+
from collections.abc import Sequence
30+
2831
TimeSeriesFilter = Optional[Callable[[NDArray[np.float64]], NDArray[np.float64]]]
2932
"""A filter that receives a time series and returns its filtered version. Used by the BaseLoss constructor."""
3033

black_it/plot/plot_results.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import pickle # nosec B403
2121
from pathlib import Path
22-
from typing import TYPE_CHECKING, Collection
22+
from typing import TYPE_CHECKING
2323

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

3232
if TYPE_CHECKING:
3333
import os
34+
from collections.abc import Collection
3435

3536

3637
def _get_samplers_id_table(saving_folder: str | os.PathLike) -> dict[str, int]:

black_it/samplers/halton.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@
1818
from __future__ import annotations
1919

2020
import itertools
21-
from typing import TYPE_CHECKING, Iterator
21+
from typing import TYPE_CHECKING
2222

2323
import numpy as np
2424

2525
from black_it.samplers.base import BaseSampler
2626
from black_it.utils.base import check_arg, digitize_data
2727

2828
if TYPE_CHECKING:
29+
from collections.abc import Iterator
30+
2931
from numpy.typing import NDArray
3032

3133
from black_it.search_space import SearchSpace

black_it/schedulers/base.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919

2020
import contextlib
2121
from abc import ABC, abstractmethod
22-
from typing import TYPE_CHECKING, Generator, Sequence
22+
from typing import TYPE_CHECKING
2323

2424
from black_it.utils.seedable import BaseSeedable
2525

2626
if TYPE_CHECKING:
27+
from collections.abc import Generator, Sequence
28+
2729
import numpy as np
2830
from numpy.typing import NDArray
2931

black_it/schedulers/rl/rl_scheduler.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from __future__ import annotations
1919

2020
import threading
21-
from typing import TYPE_CHECKING, List, Sequence, cast
21+
from typing import TYPE_CHECKING, cast
2222

2323
import numpy as np
2424

@@ -27,6 +27,7 @@
2727
from black_it.schedulers.base import BaseScheduler
2828

2929
if TYPE_CHECKING:
30+
from collections.abc import Sequence
3031
from queue import Queue
3132

3233
from numpy._typing import NDArray
@@ -103,7 +104,7 @@ def _add_or_get_bootstrap_sampler(
103104
return samplers, sampler_types[HaltonSampler]
104105

105106
new_sampler = HaltonSampler(batch_size=1)
106-
return tuple(list(samplers) + cast(List[BaseSampler], [new_sampler])), len(
107+
return tuple(list(samplers) + cast(list[BaseSampler], [new_sampler])), len(
107108
samplers,
108109
)
109110

black_it/utils/json_pandas_checkpointing.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import json
2121
import pickle # nosec B403
2222
from pathlib import Path
23-
from typing import TYPE_CHECKING, Mapping
23+
from typing import TYPE_CHECKING
2424

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

3131
if TYPE_CHECKING:
32+
from collections.abc import Mapping
33+
3234
from numpy.typing import NDArray
3335

3436
from black_it.loss_functions.base import BaseLoss

black_it/utils/sqlite3_checkpointing.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@
2323
import pickle # nosec B403
2424
import sqlite3
2525
from pathlib import Path
26-
from typing import TYPE_CHECKING, Mapping, Sequence
26+
from typing import TYPE_CHECKING
2727

2828
import numpy as np
2929
from numpy.typing import NDArray
3030

3131
if TYPE_CHECKING:
32+
from collections.abc import Mapping, Sequence
33+
3234
from black_it.loss_functions.base import BaseLoss
3335
from black_it.samplers.base import BaseSampler
3436
from black_it.utils.base import PathLike

examples/models/economics/brock_hommes.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
"""Implementation of the model in (Brock and Hommes, 1998)."""
1818
from __future__ import annotations
1919

20-
from typing import TYPE_CHECKING, Sequence
20+
from typing import TYPE_CHECKING
2121

2222
import numpy as np
2323
from scipy.special import softmax
2424

2525
if TYPE_CHECKING:
26+
from collections.abc import Sequence
27+
2628
from numpy.typing import NDArray
2729

2830

examples/models/simple_models.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@
2828
"""
2929
from __future__ import annotations
3030

31-
from typing import TYPE_CHECKING, Sequence
31+
from typing import TYPE_CHECKING
3232

3333
import numpy as np
3434
from scipy.stats import alpha, bernoulli
3535

3636
if TYPE_CHECKING:
37+
from collections.abc import Sequence
38+
3739
from numpy.typing import NDArray
3840

3941

tests/test_examples/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
"""Base module for example tests."""
1818
import sys
19+
from collections.abc import Sequence
1920
from pathlib import Path
20-
from typing import Sequence
2121

2222
import pytest
2323

tests/test_plot/base.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@
2020
import logging
2121
from pathlib import Path
2222
from tempfile import TemporaryDirectory
23-
from typing import Any, Callable, Sequence
23+
from typing import TYPE_CHECKING, Any, Callable
2424

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

28+
if TYPE_CHECKING:
29+
from collections.abc import Sequence
30+
2831

2932
class BasePlotTest:
3033
"""Base test class for plotting functions."""

tests/test_plot/test_plot_descriptive_statistics.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"""This test module contains tests for the plot_descriptive_statistics.py module."""
1818
from __future__ import annotations
1919

20-
from typing import Any, Sequence
20+
from typing import TYPE_CHECKING, Any
2121

2222
import numpy as np
2323

@@ -26,6 +26,9 @@
2626
from tests.test_plot.base import BasePlotTest
2727
from tests.utils.base import skip_on_windows
2828

29+
if TYPE_CHECKING:
30+
from collections.abc import Sequence
31+
2932

3033
@skip_on_windows()
3134
class TestTsStats(BasePlotTest):

0 commit comments

Comments
 (0)