Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace pre-commit in the CI #1666

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
4 changes: 2 additions & 2 deletions river/anomaly/pad.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ 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
# it is a time-series forecaster.
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
Expand Down
2 changes: 1 addition & 1 deletion river/preprocessing/scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions river/stream/qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
Loading