From f0f2beafef975e3f02dcb5ca4076bdcd960e232b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20Royer?= Date: Wed, 15 Jan 2025 18:15:43 +0100 Subject: [PATCH 1/2] Replace pre-commit in CI with explicit checks --- .github/workflows/code-quality.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 9f00ead2d2..48b9a68b18 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -20,5 +20,11 @@ jobs: python-version: "3.13" build-root: false - - name: Run pre-commit on all files - run: poetry run pre-commit run --all-files + - name: MyPy type check + run: poetry run mypy + + - name: Ruff code linting + run: poetry run ruff check --output-format=github river/ + + - name: Ruff code formatting + run: poetry run ruff format --check river/ From c2a4aa9cd6c82bbb5fe90345aea2087cee5aefb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20Royer?= Date: Thu, 16 Jan 2025 14:57:06 +0100 Subject: [PATCH 2/2] Ignore the remaining MyPy typing errors --- river/anomaly/pad.py | 4 ++-- river/preprocessing/scale.py | 2 +- river/stream/qa.py | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/river/anomaly/pad.py b/river/anomaly/pad.py index 0ddd3a403f..edbada3fc4 100644 --- a/river/anomaly/pad.py +++ b/river/anomaly/pad.py @@ -130,7 +130,7 @@ def learn_one(self, x: dict | None, y: base.typing.Target | float): else: self.predictive_model.learn_one(y=y, x=x) else: - self.predictive_model.learn_one(x=x, y=y) + self.predictive_model.learn_one(x=x, y=y) # type: ignore[union-attr] def score_one(self, x: dict, y: base.typing.Target): # Return the predicted value of x from the predictive model, first by checking whether @@ -138,7 +138,7 @@ def score_one(self, x: dict, y: base.typing.Target): if isinstance(self.predictive_model, time_series.base.Forecaster): y_pred = self.predictive_model.forecast(self.horizon)[0] else: - y_pred = self.predictive_model.predict_one(x) + y_pred = self.predictive_model.predict_one(x) # type: ignore[union-attr] # Calculate the squared error squared_error = (y_pred - y) ** 2 diff --git a/river/preprocessing/scale.py b/river/preprocessing/scale.py index eab0a68966..c17813cd4e 100644 --- a/river/preprocessing/scale.py +++ b/river/preprocessing/scale.py @@ -237,7 +237,7 @@ def transform_many(self, X: pd.DataFrame): # Check if the dtype is integer type and convert to corresponding float type if np.issubdtype(dtype, np.integer): bytes_size = dtype.itemsize - dtype = np.dtype(f"float{bytes_size * 8}") + dtype = np.dtype(f"float{bytes_size * 8}") # type: ignore[operator] means = np.array([self.means[c] for c in X.columns], dtype=dtype) Xt = X.values - means diff --git a/river/stream/qa.py b/river/stream/qa.py index 54f2ca639d..d9f5da89e2 100644 --- a/river/stream/qa.py +++ b/river/stream/qa.py @@ -140,10 +140,10 @@ def simulate_qa( mementos: list[Memento] = [] - kwargs: list + kwargs_list: list - for i, (x, y, *kwargs) in enumerate(dataset): - kwargs = kwargs[0] if kwargs else None + for i, (x, y, *kwargs_list) in enumerate(dataset): + kwargs = kwargs_list[0] if kwargs_list else None t = get_moment(i, x) d = get_delay(x, y) # type: ignore @@ -168,7 +168,7 @@ def simulate_qa( ) del mementos[0] - queue(mementos, Memento(i, x, y, kwargs, t + d)) + queue(mementos, Memento(i, x, y, kwargs, t + d)) # type: ignore[operator] if copy: x = deepcopy(x) yield (i, x, None, kwargs) if kwargs else (i, x, None)