From bd8a6bd2d4a0c5e694b1af888df9cb364dbdd9dd Mon Sep 17 00:00:00 2001 From: Nick Frasser <1693461+nfrasser@users.noreply.github.com> Date: Mon, 26 Aug 2024 17:03:56 -0400 Subject: [PATCH] Fix: correct pre-commit lint config (#94) Ruff actually gets applied correctly now --- .pre-commit-config.yaml | 12 ++++++++++-- cryosparc/dataset.py | 4 ++-- docs/examples/connect_series_to_class3D.ipynb | 4 ++-- tests/test_dataset.py | 4 ++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ea07f035..6c1b807c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,13 +10,21 @@ repos: - id: check-yaml - id: check-added-large-files - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.6 + rev: v0.6.2 hooks: - id: ruff + name: ruff check + alias: check + args: [--fix] + - id: ruff + name: ruff check imports + alias: check-imports args: [--fix, --select, I, --exit-non-zero-on-fix] - id: ruff-format + name: ruff format + alias: format - repo: https://github.com/RobertCraigie/pyright-python - rev: v1.1.374 + rev: v1.1.377 hooks: - id: pyright additional_dependencies: [cython, httpretty, numpy, pytest] diff --git a/cryosparc/dataset.py b/cryosparc/dataset.py index 300d6626..4790cbfe 100644 --- a/cryosparc/dataset.py +++ b/cryosparc/dataset.py @@ -501,7 +501,7 @@ def innerjoin_many(cls, *datasets: "Dataset"): # [0,1,2]}), …]. This is faster than doing the innerjoin for all columns # and safer because we don't have to worry about not updating Python # string reference counts in the resulting dataset. - indexed_dsets = [Dataset({"uid": d["uid"], f"idx{i}": n.arange(len(d))}) for i, d in enumerate(datasets)] + indexed_dsets = [cls({"uid": d["uid"], f"idx{i}": n.arange(len(d))}) for i, d in enumerate(datasets)] indexed_dset = reduce(lambda dr, ds: cls(dr._data.innerjoin("uid", ds._data)), indexed_dsets) result = cls({"uid": indexed_dset["uid"]}) result.add_fields(all_fields) @@ -856,7 +856,7 @@ def __eq__(self, other: object): """ return ( isinstance(other, type(self)) - and type(self) == type(other) + and type(self) is type(other) and len(self) == len(other) and self.descr() == other.descr() and all(n.array_equal(self[c1], other[c2]) for c1, c2 in zip(self, other)) diff --git a/docs/examples/connect_series_to_class3D.ipynb b/docs/examples/connect_series_to_class3D.ipynb index 43f8b9e0..5bec5880 100644 --- a/docs/examples/connect_series_to_class3D.ipynb +++ b/docs/examples/connect_series_to_class3D.ipynb @@ -79,11 +79,11 @@ } ], "source": [ + "import zipfile\n", + "\n", "unzip_path = series_path[:-4]\n", "print(unzip_path)\n", "\n", - "import zipfile\n", - "\n", "with zipfile.ZipFile(series_path, \"r\") as z:\n", " z.extractall(unzip_path)" ] diff --git a/tests/test_dataset.py b/tests/test_dataset.py index 8f713d38..2c09a082 100644 --- a/tests/test_dataset.py +++ b/tests/test_dataset.py @@ -254,8 +254,8 @@ def test_pickle_unpickle(): def test_column_aggregation(t20s_dset): - assert type(t20s_dset["uid"]) == Column - assert type(n.max(t20s_dset["uid"])) == n.uint64 + assert type(t20s_dset["uid"]) is Column + assert type(n.max(t20s_dset["uid"])) is n.uint64 assert isinstance(n.mean(t20s_dset["uid"]), n.number) assert not isinstance(n.mean(t20s_dset["uid"]), n.ndarray)