Skip to content

Commit 9f14e63

Browse files
ci(pre-commit.ci): autoupdate (#509)
<!--pre-commit.ci start--> updates: - [github.com/astral-sh/ruff-pre-commit: v0.11.12 → v0.12.2](astral-sh/ruff-pre-commit@v0.11.12...v0.12.2) - [github.com/pre-commit/mirrors-mypy: v1.16.0 → v1.16.1](pre-commit/mirrors-mypy@v1.16.0...v1.16.1) - [github.com/numpy/numpydoc: v1.8.0 → v1.9.0](numpy/numpydoc@v1.8.0...v1.9.0) <!--pre-commit.ci end--> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 9a1723f commit 9f14e63

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+384
-423
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repos:
1414
- id: validate-pyproject
1515

1616
- repo: https://github.com/astral-sh/ruff-pre-commit
17-
rev: v0.11.12
17+
rev: v0.12.2
1818
hooks:
1919
- id: ruff
2020
exclude: "^src/careamics/lvae_training/.*|^src/careamics/models/lvae/.*|^scripts/.*"
@@ -26,7 +26,7 @@ repos:
2626
- id: black
2727

2828
- repo: https://github.com/pre-commit/mirrors-mypy
29-
rev: v1.16.0
29+
rev: v1.16.1
3030
hooks:
3131
- id: mypy
3232
files: "^src/"
@@ -40,7 +40,7 @@ repos:
4040

4141
# check docstrings
4242
- repo: https://github.com/numpy/numpydoc
43-
rev: v1.8.0
43+
rev: v1.9.0
4444
hooks:
4545
- id: numpydoc-validation
4646
exclude: "^src/careamics/dataset_ng/.*|^src/careamics/lvae_training/.*|^src/careamics/models/lvae/.*|^src/careamics/losses/lvae/.*|^src/careamics/lightning/dataset_ng/data_module.py|^scripts/.*"

src/careamics/careamist.py

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from collections.abc import Callable
44
from pathlib import Path
5-
from typing import Any, Literal, Optional, Union, overload
5+
from typing import Any, Literal, Union, overload
66

77
import numpy as np
88
from numpy.typing import NDArray
@@ -79,25 +79,25 @@ class CAREamist:
7979
def __init__( # numpydoc ignore=GL08
8080
self,
8181
source: Union[Path, str],
82-
work_dir: Optional[Union[Path, str]] = None,
83-
callbacks: Optional[list[Callback]] = None,
82+
work_dir: Union[Path, str] | None = None,
83+
callbacks: list[Callback] | None = None,
8484
enable_progress_bar: bool = True,
8585
) -> None: ...
8686

8787
@overload
8888
def __init__( # numpydoc ignore=GL08
8989
self,
9090
source: Configuration,
91-
work_dir: Optional[Union[Path, str]] = None,
92-
callbacks: Optional[list[Callback]] = None,
91+
work_dir: Union[Path, str] | None = None,
92+
callbacks: list[Callback] | None = None,
9393
enable_progress_bar: bool = True,
9494
) -> None: ...
9595

9696
def __init__(
9797
self,
9898
source: Union[Path, str, Configuration],
99-
work_dir: Optional[Union[Path, str]] = None,
100-
callbacks: Optional[list[Callback]] = None,
99+
work_dir: Union[Path, str] | None = None,
100+
callbacks: list[Callback] | None = None,
101101
enable_progress_bar: bool = True,
102102
) -> None:
103103
"""
@@ -222,11 +222,11 @@ def __init__(
222222
)
223223

224224
# place holder for the datamodules
225-
self.train_datamodule: Optional[TrainDataModule] = None
226-
self.pred_datamodule: Optional[PredictDataModule] = None
225+
self.train_datamodule: TrainDataModule | None = None
226+
self.pred_datamodule: PredictDataModule | None = None
227227

228228
def _define_callbacks(
229-
self, callbacks: Optional[list[Callback]], enable_progress_bar: bool
229+
self, callbacks: list[Callback] | None, enable_progress_bar: bool
230230
) -> None:
231231
"""Define the callbacks for the training loop.
232232
@@ -288,11 +288,11 @@ def stop_training(self) -> None:
288288
def train(
289289
self,
290290
*,
291-
datamodule: Optional[TrainDataModule] = None,
292-
train_source: Optional[Union[Path, str, NDArray]] = None,
293-
val_source: Optional[Union[Path, str, NDArray]] = None,
294-
train_target: Optional[Union[Path, str, NDArray]] = None,
295-
val_target: Optional[Union[Path, str, NDArray]] = None,
291+
datamodule: TrainDataModule | None = None,
292+
train_source: Union[Path, str, NDArray] | None = None,
293+
val_source: Union[Path, str, NDArray] | None = None,
294+
train_target: Union[Path, str, NDArray] | None = None,
295+
val_target: Union[Path, str, NDArray] | None = None,
296296
use_in_memory: bool = True,
297297
val_percentage: float = 0.1,
298298
val_minimum_split: int = 1,
@@ -443,9 +443,9 @@ def _train_on_datamodule(self, datamodule: TrainDataModule) -> None:
443443
def _train_on_array(
444444
self,
445445
train_data: NDArray,
446-
val_data: Optional[NDArray] = None,
447-
train_target: Optional[NDArray] = None,
448-
val_target: Optional[NDArray] = None,
446+
val_data: NDArray | None = None,
447+
train_target: NDArray | None = None,
448+
val_target: NDArray | None = None,
449449
val_percentage: float = 0.1,
450450
val_minimum_split: int = 5,
451451
) -> None:
@@ -484,9 +484,9 @@ def _train_on_array(
484484
def _train_on_path(
485485
self,
486486
path_to_train_data: Union[Path, str],
487-
path_to_val_data: Optional[Union[Path, str]] = None,
488-
path_to_train_target: Optional[Union[Path, str]] = None,
489-
path_to_val_target: Optional[Union[Path, str]] = None,
487+
path_to_val_data: Union[Path, str] | None = None,
488+
path_to_train_target: Union[Path, str] | None = None,
489+
path_to_val_target: Union[Path, str] | None = None,
490490
use_in_memory: bool = True,
491491
val_percentage: float = 0.1,
492492
val_minimum_split: int = 1,
@@ -549,13 +549,13 @@ def predict( # numpydoc ignore=GL08
549549
source: Union[Path, str],
550550
*,
551551
batch_size: int = 1,
552-
tile_size: Optional[tuple[int, ...]] = None,
553-
tile_overlap: Optional[tuple[int, ...]] = (48, 48),
554-
axes: Optional[str] = None,
555-
data_type: Optional[Literal["tiff", "custom"]] = None,
552+
tile_size: tuple[int, ...] | None = None,
553+
tile_overlap: tuple[int, ...] | None = (48, 48),
554+
axes: str | None = None,
555+
data_type: Literal["tiff", "custom"] | None = None,
556556
tta_transforms: bool = False,
557-
dataloader_params: Optional[dict] = None,
558-
read_source_func: Optional[Callable] = None,
557+
dataloader_params: dict | None = None,
558+
read_source_func: Callable | None = None,
559559
extension_filter: str = "",
560560
) -> Union[list[NDArray], NDArray]: ...
561561

@@ -565,26 +565,26 @@ def predict( # numpydoc ignore=GL08
565565
source: NDArray,
566566
*,
567567
batch_size: int = 1,
568-
tile_size: Optional[tuple[int, ...]] = None,
569-
tile_overlap: Optional[tuple[int, ...]] = (48, 48),
570-
axes: Optional[str] = None,
571-
data_type: Optional[Literal["array"]] = None,
568+
tile_size: tuple[int, ...] | None = None,
569+
tile_overlap: tuple[int, ...] | None = (48, 48),
570+
axes: str | None = None,
571+
data_type: Literal["array"] | None = None,
572572
tta_transforms: bool = False,
573-
dataloader_params: Optional[dict] = None,
573+
dataloader_params: dict | None = None,
574574
) -> Union[list[NDArray], NDArray]: ...
575575

576576
def predict(
577577
self,
578578
source: Union[PredictDataModule, Path, str, NDArray],
579579
*,
580580
batch_size: int = 1,
581-
tile_size: Optional[tuple[int, ...]] = None,
582-
tile_overlap: Optional[tuple[int, ...]] = (48, 48),
583-
axes: Optional[str] = None,
584-
data_type: Optional[Literal["array", "tiff", "custom"]] = None,
581+
tile_size: tuple[int, ...] | None = None,
582+
tile_overlap: tuple[int, ...] | None = (48, 48),
583+
axes: str | None = None,
584+
data_type: Literal["array", "tiff", "custom"] | None = None,
585585
tta_transforms: bool = False,
586-
dataloader_params: Optional[dict] = None,
587-
read_source_func: Optional[Callable] = None,
586+
dataloader_params: dict | None = None,
587+
read_source_func: Callable | None = None,
588588
extension_filter: str = "",
589589
**kwargs: Any,
590590
) -> Union[list[NDArray], NDArray]:
@@ -704,18 +704,18 @@ def predict_to_disk(
704704
source: Union[PredictDataModule, Path, str],
705705
*,
706706
batch_size: int = 1,
707-
tile_size: Optional[tuple[int, ...]] = None,
708-
tile_overlap: Optional[tuple[int, ...]] = (48, 48),
709-
axes: Optional[str] = None,
710-
data_type: Optional[Literal["tiff", "custom"]] = None,
707+
tile_size: tuple[int, ...] | None = None,
708+
tile_overlap: tuple[int, ...] | None = (48, 48),
709+
axes: str | None = None,
710+
data_type: Literal["tiff", "custom"] | None = None,
711711
tta_transforms: bool = False,
712-
dataloader_params: Optional[dict] = None,
713-
read_source_func: Optional[Callable] = None,
712+
dataloader_params: dict | None = None,
713+
read_source_func: Callable | None = None,
714714
extension_filter: str = "",
715715
write_type: Literal["tiff", "custom"] = "tiff",
716-
write_extension: Optional[str] = None,
717-
write_func: Optional[WriteFunc] = None,
718-
write_func_kwargs: Optional[dict[str, Any]] = None,
716+
write_extension: str | None = None,
717+
write_func: WriteFunc | None = None,
718+
write_func_kwargs: dict[str, Any] | None = None,
719719
prediction_dir: Union[Path, str] = "predictions",
720720
**kwargs,
721721
) -> None:
@@ -885,8 +885,8 @@ def export_to_bmz(
885885
authors: list[dict],
886886
general_description: str,
887887
data_description: str,
888-
covers: Optional[list[Union[Path, str]]] = None,
889-
channel_names: Optional[list[str]] = None,
888+
covers: list[Union[Path, str]] | None = None,
889+
channel_names: list[str] | None = None,
890890
model_version: str = "0.1.0",
891891
) -> None:
892892
"""Export the model to the BioImage Model Zoo format.

src/careamics/cli/conf.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44
from dataclasses import dataclass
55
from pathlib import Path
6-
from typing import Annotated, Optional
6+
from typing import Annotated
77

88
import click
99
import typer
@@ -135,10 +135,10 @@ def care( # numpydoc ignore=PR01
135135
),
136136
] = "mae",
137137
n_channels_in: Annotated[
138-
Optional[int], typer.Option(help="Number of channels in")
138+
int | None, typer.Option(help="Number of channels in")
139139
] = None,
140140
n_channels_out: Annotated[
141-
Optional[int], typer.Option(help="Number of channels out")
141+
int | None, typer.Option(help="Number of channels out")
142142
] = None,
143143
logger: Annotated[
144144
click.Choice,
@@ -222,10 +222,10 @@ def n2n( # numpydoc ignore=PR01
222222
),
223223
] = "mae",
224224
n_channels_in: Annotated[
225-
Optional[int], typer.Option(help="Number of channels in")
225+
int | None, typer.Option(help="Number of channels in")
226226
] = None,
227227
n_channels_out: Annotated[
228-
Optional[int], typer.Option(help="Number of channels out")
228+
int | None, typer.Option(help="Number of channels out")
229229
] = None,
230230
logger: Annotated[
231231
click.Choice,
@@ -300,7 +300,7 @@ def n2v( # numpydoc ignore=PR01
300300
] = True,
301301
use_n2v2: Annotated[bool, typer.Option(help="Whether to use N2V2")] = False,
302302
n_channels: Annotated[
303-
Optional[int], typer.Option(help="Number of channels (in and out)")
303+
int | None, typer.Option(help="Number of channels (in and out)")
304304
] = None,
305305
roi_size: Annotated[int, typer.Option(help="N2V pixel manipulation area.")] = 11,
306306
masked_pixel_percentage: Annotated[

src/careamics/cli/main.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88

99
from pathlib import Path
10-
from typing import Annotated, Optional
10+
from typing import Annotated
1111

1212
import click
1313
import typer
@@ -47,7 +47,7 @@ def train( # numpydoc ignore=PR01
4747
),
4848
],
4949
train_target: Annotated[
50-
Optional[Path],
50+
Path | None,
5151
typer.Option(
5252
"--train-target",
5353
"-tt",
@@ -58,7 +58,7 @@ def train( # numpydoc ignore=PR01
5858
),
5959
] = None,
6060
val_source: Annotated[
61-
Optional[Path],
61+
Path | None,
6262
typer.Option(
6363
"--val-source",
6464
"-vs",
@@ -69,7 +69,7 @@ def train( # numpydoc ignore=PR01
6969
),
7070
] = None,
7171
val_target: Annotated[
72-
Optional[Path],
72+
Path | None,
7373
typer.Option(
7474
"--val-target",
7575
"-vt",
@@ -96,7 +96,7 @@ def train( # numpydoc ignore=PR01
9696
typer.Option(help="Minimum number of files to use for validation,"),
9797
] = 1,
9898
work_dir: Annotated[
99-
Optional[Path],
99+
Path | None,
100100
typer.Option(
101101
"--work-dir",
102102
"-wd",
@@ -142,7 +142,7 @@ def predict( # numpydoc ignore=PR01
142142
],
143143
batch_size: Annotated[int, typer.Option(help="Batch size.")] = 1,
144144
tile_size: Annotated[
145-
Optional[click.Tuple],
145+
click.Tuple | None,
146146
typer.Option(
147147
help=(
148148
"Size of the tiles to use for prediction, (if the data "
@@ -164,7 +164,7 @@ def predict( # numpydoc ignore=PR01
164164
),
165165
] = (48, 48, -1),
166166
axes: Annotated[
167-
Optional[str],
167+
str | None,
168168
typer.Option(
169169
help="Axes of the input data. If unused the data is assumed to have the "
170170
"same axes as the original training data."
@@ -190,7 +190,7 @@ def predict( # numpydoc ignore=PR01
190190
] = "tiff",
191191
# TODO: could make dataloader_params as json, necessary?
192192
work_dir: Annotated[
193-
Optional[Path],
193+
Path | None,
194194
typer.Option(
195195
"--work-dir",
196196
"-wd",

src/careamics/cli/utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
"""Utility functions for the CAREamics CLI."""
22

3-
from typing import Optional
4-
53

64
def handle_2D_3D_callback(
7-
value: Optional[tuple[int, int, int]],
8-
) -> Optional[tuple[int, ...]]:
5+
value: tuple[int, int, int] | None,
6+
) -> tuple[int, ...] | None:
97
"""
108
Callback for options that require 2D or 3D inputs.
119

src/careamics/config/algorithms/vae_algorithm_model.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
from pprint import pformat
6-
from typing import Literal, Optional
6+
from typing import Literal
77

88
from pydantic import BaseModel, ConfigDict, model_validator
99
from typing_extensions import Self
@@ -45,9 +45,9 @@ class VAEBasedAlgorithm(BaseModel):
4545
# NOTE: these are all configs (pydantic models)
4646
loss: LVAELossConfig
4747
model: LVAEModel
48-
noise_model: Optional[MultiChannelNMConfig] = None
49-
noise_model_likelihood: Optional[NMLikelihoodConfig] = None
50-
gaussian_likelihood: Optional[GaussianLikelihoodConfig] = None
48+
noise_model: MultiChannelNMConfig | None = None
49+
noise_model_likelihood: NMLikelihoodConfig | None = None
50+
gaussian_likelihood: GaussianLikelihoodConfig | None = None
5151

5252
# Optional fields
5353
optimizer: OptimizerModel = OptimizerModel()

0 commit comments

Comments
 (0)