Skip to content

Commit

Permalink
chore: Replace all | in typehints with typing.Union
Browse files Browse the repository at this point in the history
  • Loading branch information
augustebaum committed Jan 14, 2025
1 parent a379189 commit 4a038c7
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 61 deletions.
20 changes: 10 additions & 10 deletions skore/src/skore/externals/_sklearn_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import sys
import types
from dataclasses import dataclass, field
from typing import Callable, Literal
from typing import Callable, Literal, Union

import sklearn
from sklearn.utils.fixes import parse_version
Expand Down Expand Up @@ -775,11 +775,11 @@ class Tags:
The input data(X) tags.
"""

estimator_type: str | None
estimator_type: Union[str, None]
target_tags: TargetTags
transformer_tags: TransformerTags | None = None
classifier_tags: ClassifierTags | None = None
regressor_tags: RegressorTags | None = None
transformer_tags: Union[TransformerTags, None] = None
classifier_tags: Union[ClassifierTags, None] = None
regressor_tags: Union[RegressorTags, None] = None
array_api_support: bool = False
no_validation: bool = False
non_deterministic: bool = False
Expand Down Expand Up @@ -808,10 +808,10 @@ def check_estimator(
generate_only=False,
*,
legacy: bool = True,
expected_failed_checks: dict[str, str] | None = None,
on_skip: Literal["warn"] | None = "warn",
on_fail: Literal["raise", "warn"] | None = "raise",
callback: Callable | None = None,
expected_failed_checks: Union[dict[str, str], None] = None,
on_skip: Union[Literal["warn"], None] = "warn",
on_fail: Union[Literal["raise", "warn"], None] = "raise",
callback: Union[Callable, None] = None,
):
# legacy, on_skip, on_fail, and callback are not supported and ignored
from sklearn.utils.estimator_checks import check_estimator
Expand All @@ -825,7 +825,7 @@ def parametrize_with_checks(
estimators,
*,
legacy: bool = True,
expected_failed_checks: Callable | None = None,
expected_failed_checks: Union[Callable, None] = None,
):
# legacy is not supported and ignored
from sklearn.utils.estimator_checks import parametrize_with_checks
Expand Down
12 changes: 6 additions & 6 deletions skore/src/skore/item/cross_validation_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import re
import statistics
from functools import cached_property
from typing import TYPE_CHECKING, Any, Literal, TypedDict
from typing import TYPE_CHECKING, Any, Literal, TypedDict, Union

import numpy
import plotly.graph_objects
Expand Down Expand Up @@ -136,12 +136,12 @@ def __init__(
cv_results_serialized: dict,
estimator_info: EstimatorInfo,
X_info: dict,
y_info: dict | None,
y_info: Union[dict, None],
plots_bytes: dict[str, bytes],
cv_info: dict,
created_at: str | None = None,
updated_at: str | None = None,
note: str | None = None,
created_at: Union[str, None] = None,
updated_at: Union[str, None] = None,
note: Union[str, None] = None,
):
"""
Initialize a CrossValidationItem.
Expand All @@ -167,7 +167,7 @@ def __init__(
The creation timestamp in ISO format.
updated_at : str
The last update timestamp in ISO format.
note : str | None
note : Union[str, None]
An optional note.
"""
super().__init__(created_at, updated_at, note)
Expand Down
8 changes: 4 additions & 4 deletions skore/src/skore/item/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ class Item(ABC):
Parameters
----------
created_at : str | None, optional
created_at : Union[str, None], optional
The creation timestamp of the item. If None, the current time is used.
updated_at : str | None, optional
updated_at : Union[str, None], optional
The last update timestamp of the item. If None, the current time is used.
note : str | None
note : Union[str, None]
An optional note.
Attributes
Expand All @@ -43,7 +43,7 @@ class Item(ABC):
The creation timestamp of the item.
updated_at : str
The last update timestamp of the item.
note : str | None
note : Union[str, None]
An optional note.
"""

Expand Down
2 changes: 1 addition & 1 deletion skore/src/skore/item/item_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def set_item_note(self, key: str, message: str, *, version=-1):
except IndexError as e:
raise KeyError((key, version)) from e

def get_item_note(self, key: str, *, version=-1) -> str | None:
def get_item_note(self, key: str, *, version=-1) -> Union[str, None]:
"""Retrieve a note previously attached to key ``key``.
Parameters
Expand Down
10 changes: 5 additions & 5 deletions skore/src/skore/item/media_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import base64
from io import BytesIO
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, Union

from skore.item.item import Item, ItemTypeError

Expand Down Expand Up @@ -37,9 +37,9 @@ def __init__(
media_bytes: bytes,
media_encoding: str,
media_type: str,
created_at: str | None = None,
updated_at: str | None = None,
note: str | None = None,
created_at: Union[str, None] = None,
updated_at: Union[str, None] = None,
note: Union[str, None] = None,
):
"""
Initialize a MediaItem.
Expand All @@ -56,7 +56,7 @@ def __init__(
The creation timestamp in ISO format.
updated_at : str, optional
The last update timestamp in ISO format.
note : str | None
note : Union[str, None]
An optional note.
"""
super().__init__(created_at, updated_at, note)
Expand Down
10 changes: 5 additions & 5 deletions skore/src/skore/item/numpy_array_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from functools import cached_property
from json import dumps, loads
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Union

from skore.item.item import Item, ItemTypeError

Expand All @@ -25,9 +25,9 @@ class NumpyArrayItem(Item):
def __init__(
self,
array_json: str,
created_at: str | None = None,
updated_at: str | None = None,
note: str | None = None,
created_at: Union[str, None] = None,
updated_at: Union[str, None] = None,
note: Union[str, None] = None,
):
"""
Initialize a NumpyArrayItem.
Expand All @@ -40,7 +40,7 @@ def __init__(
The creation timestamp in ISO format.
updated_at : str
The last update timestamp in ISO format.
note : str | None
note : Union[str, None]
An optional note.
"""
super().__init__(created_at, updated_at, note)
Expand Down
10 changes: 5 additions & 5 deletions skore/src/skore/item/pandas_dataframe_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from __future__ import annotations

from functools import cached_property
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Union

from skore.item.item import Item, ItemTypeError

Expand All @@ -29,9 +29,9 @@ def __init__(
self,
index_json: str,
dataframe_json: str,
created_at: str | None = None,
updated_at: str | None = None,
note: str | None = None,
created_at: Union[str, None] = None,
updated_at: Union[str, None] = None,
note: Union[str, None] = None,
):
"""
Initialize a PandasDataFrameItem.
Expand All @@ -46,7 +46,7 @@ def __init__(
The creation timestamp in ISO format.
updated_at : str
The last update timestamp in ISO format.
note : str | None
note : Union[str, None]
An optional note.
"""
super().__init__(created_at, updated_at, note)
Expand Down
10 changes: 5 additions & 5 deletions skore/src/skore/item/pandas_series_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from __future__ import annotations

from functools import cached_property
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Union

from skore.item.item import Item, ItemTypeError

Expand All @@ -29,9 +29,9 @@ def __init__(
self,
index_json: str,
series_json: str,
created_at: str | None = None,
updated_at: str | None = None,
note: str | None = None,
created_at: Union[str, None] = None,
updated_at: Union[str, None] = None,
note: Union[str, None] = None,
):
"""
Initialize a PandasSeriesItem.
Expand All @@ -46,7 +46,7 @@ def __init__(
The creation timestamp in ISO format.
updated_at : str
The last update timestamp in ISO format.
note : str | None
note : Union[str, None]
An optional note.
"""
super().__init__(created_at, updated_at, note)
Expand Down
10 changes: 5 additions & 5 deletions skore/src/skore/item/polars_dataframe_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from __future__ import annotations

from functools import cached_property
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Union

from skore.item.item import Item, ItemTypeError

Expand All @@ -30,9 +30,9 @@ class PolarsDataFrameItem(Item):
def __init__(
self,
dataframe_json: str,
created_at: str | None = None,
updated_at: str | None = None,
note: str | None = None,
created_at: Union[str, None] = None,
updated_at: Union[str, None] = None,
note: Union[str, None] = None,
):
"""
Initialize a PolarsDataFrameItem.
Expand All @@ -45,7 +45,7 @@ def __init__(
The creation timestamp in ISO format.
updated_at : str
The last update timestamp in ISO format.
note : str | None
note : Union[str, None]
An optional note.
"""
super().__init__(created_at, updated_at, note)
Expand Down
10 changes: 5 additions & 5 deletions skore/src/skore/item/polars_series_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from __future__ import annotations

from functools import cached_property
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Union

from skore.item.item import Item, ItemTypeError

Expand All @@ -26,9 +26,9 @@ class PolarsSeriesItem(Item):
def __init__(
self,
series_json: str,
created_at: str | None = None,
updated_at: str | None = None,
note: str | None = None,
created_at: Union[str, None] = None,
updated_at: Union[str, None] = None,
note: Union[str, None] = None,
):
"""
Initialize a PolarsSeriesItem.
Expand All @@ -41,7 +41,7 @@ def __init__(
The creation timestamp in ISO format.
updated_at : str
The last update timestamp in ISO format.
note : str | None
note : Union[str, None]
An optional note.
"""
super().__init__(created_at, updated_at, note)
Expand Down
10 changes: 5 additions & 5 deletions skore/src/skore/item/primitive_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
str,
list["Primitive"],
tuple["Primitive"],
dict[str | int | float, "Primitive"],
dict[Union[str, int, float], "Primitive"],
]


Expand Down Expand Up @@ -48,9 +48,9 @@ class PrimitiveItem(Item):
def __init__(
self,
primitive: Primitive,
created_at: str | None = None,
updated_at: str | None = None,
note: str | None = None,
created_at: Union[str, None] = None,
updated_at: Union[str, None] = None,
note: Union[str, None] = None,
):
"""
Initialize a PrimitiveItem.
Expand All @@ -63,7 +63,7 @@ def __init__(
The creation timestamp as ISO format.
updated_at : str, optional
The last update timestamp as ISO format.
note : str | None
note : Union[str, None]
An optional note.
"""
super().__init__(created_at, updated_at, note)
Expand Down
10 changes: 5 additions & 5 deletions skore/src/skore/item/sklearn_base_estimator_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from __future__ import annotations

from functools import cached_property
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Union

from skore.item.item import Item, ItemTypeError

Expand All @@ -28,9 +28,9 @@ def __init__(
estimator_html_repr: str,
estimator_skops: bytes,
estimator_skops_untrusted_types: list[str],
created_at: str | None = None,
updated_at: str | None = None,
note: str | None = None,
created_at: Union[str, None] = None,
updated_at: Union[str, None] = None,
note: Union[str, None] = None,
):
"""
Initialize a SklearnBaseEstimatorItem.
Expand All @@ -47,7 +47,7 @@ def __init__(
The creation timestamp in ISO format.
updated_at : str, optional
The last update timestamp in ISO format.
note : str | None
note : Union[str, None]
An optional note.
"""
super().__init__(created_at, updated_at, note)
Expand Down

0 comments on commit 4a038c7

Please sign in to comment.