Skip to content

Commit b86a812

Browse files
committed
chore(skore-hub-project): Turn pytest warnings into errors
1 parent 414123f commit b86a812

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

skore-hub-project/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ addopts = [
5959
"--verbosity=2",
6060
"--dist=loadscope",
6161
]
62+
filterwarnings = ["error"]
6263

6364
[tool.coverage.run]
6465
branch = true

skore-hub-project/src/skore_hub_project/metric/precision.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class PrecisionTest(Precision): # noqa: D101
3838

3939
class PrecisionMean(CrossValidationReportMetric): # noqa: D101
4040
accessor: ClassVar[str] = "metrics.precision"
41-
aggregate: ClassVar[Literal["mean"]] = "mean"
4241
name: str = "precision_mean"
4342
verbose_name: str = "Precision (macro) - MEAN"
4443
greater_is_better: bool = True
@@ -53,7 +52,7 @@ def value(self) -> float | None: # noqa: D102
5352
return None
5453

5554
dataframe = function(
56-
data_source=self.data_source, aggregate=self.aggregate, average="macro"
55+
data_source=self.data_source, aggregate="mean", average="macro"
5756
)
5857

5958
return cast_to_float(dataframe.iloc[0, 0])
@@ -69,7 +68,6 @@ class PrecisionTestMean(PrecisionMean): # noqa: D101
6968

7069
class PrecisionStd(CrossValidationReportMetric): # noqa: D101
7170
accessor: ClassVar[str] = "metrics.precision"
72-
aggregate: ClassVar[Literal["std"]] = "std"
7371
name: str = "precision_std"
7472
verbose_name: str = "Precision (macro) - STD"
7573
greater_is_better: bool = False
@@ -84,7 +82,7 @@ def value(self) -> float | None: # noqa: D102
8482
return None
8583

8684
dataframe = function(
87-
data_source=self.data_source, aggregate=self.aggregate, average="macro"
85+
data_source=self.data_source, aggregate="std", average="macro"
8886
)
8987

9088
return cast_to_float(dataframe.iloc[0, 0])

skore-hub-project/tests/unit/project/test_project.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import joblib
88
from httpx import Client, Response
9-
from pytest import fixture, raises
9+
from pytest import fixture, mark, raises
1010
from skore import CrossValidationReport, EstimatorReport
1111
from skore_hub_project import Project
1212
from skore_hub_project.report import (
@@ -128,6 +128,9 @@ def test_put_estimator_report(self, monkeypatch, binary_classification, respx_mo
128128
# Compare content with the desired output
129129
assert content == desired
130130

131+
@mark.filterwarnings(
132+
"ignore:Precision is ill-defined.*:sklearn.exceptions.UndefinedMetricWarning"
133+
)
131134
def test_put_cross_validation_report(
132135
self, monkeypatch, small_cv_binary_classification, respx_mock
133136
):

skore-hub-project/tests/unit/report/test_cross_validation_report.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ def test_splits_test_samples_density_many_rows(self):
120120
def test_class_names(self, payload):
121121
assert payload.class_names == ["1", "0"]
122122

123+
@mark.filterwarnings(
124+
"ignore:The `disp` and `iprint` options.* will be removed.*:DeprecationWarning"
125+
)
123126
def test_classes(self, payload):
124127
X, y = make_classification(
125128
random_state=42,
@@ -145,6 +148,9 @@ def test_classes(self, payload):
145148
def test_classes_many_rows(self, payload):
146149
assert payload.classes == [0, 0, 1, 1, 1, 0, 0, 1, 0, 1]
147150

151+
@mark.filterwarnings(
152+
"ignore:Precision is ill-defined.*:sklearn.exceptions.UndefinedMetricWarning"
153+
)
148154
@mark.usefixtures("monkeypatch_artifact_hub_client")
149155
@mark.usefixtures("monkeypatch_upload_routes")
150156
@mark.usefixtures("monkeypatch_upload_with_mock")
@@ -192,6 +198,9 @@ def test_pickle(
192198
"content_type": "application/octet-stream",
193199
}
194200

201+
@mark.filterwarnings(
202+
"ignore:Precision is ill-defined.*:sklearn.exceptions.UndefinedMetricWarning"
203+
)
195204
def test_metrics(self, payload):
196205
assert list(map(type, payload.metrics)) == [
197206
AccuracyTestMean,
@@ -234,6 +243,9 @@ def test_medias(self, payload):
234243
TableReport,
235244
]
236245

246+
@mark.filterwarnings(
247+
"ignore:Precision is ill-defined.*:sklearn.exceptions.UndefinedMetricWarning"
248+
)
237249
@mark.usefixtures("monkeypatch_artifact_hub_client")
238250
@mark.usefixtures("monkeypatch_upload_routes")
239251
def test_model_dump(self, small_cv_binary_classification, payload):

0 commit comments

Comments
 (0)