From 9b6643b89dfeac3e96c267b34bac5fd5b3a38801 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:54:30 +0000 Subject: [PATCH 1/3] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.10 → v0.5.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.10...v0.5.0) - [github.com/pre-commit/mirrors-mypy: v1.10.0 → v1.10.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.10.0...v1.10.1) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7deb4a9..c050393 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,12 +9,12 @@ repos: hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.4.10' + rev: 'v0.5.0' hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.10.0" + rev: "v1.10.1" hooks: - id: mypy - repo: https://github.com/igorshubovych/markdownlint-cli From e2bf261bfeef6180d25ef398107409fad6b3cd89 Mon Sep 17 00:00:00 2001 From: Adrian D'Alessandro Date: Thu, 4 Jul 2024 17:00:08 +0100 Subject: [PATCH 2/3] Update ruff config and keep it happy --- pyproject.toml | 23 ++++++++++++++++------- tests/conftest.py | 2 +- tests/test_opal.py | 3 +-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 62b48cf..2c3fe8f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,11 +54,20 @@ disallow_untyped_defs = false [tool.pytest.ini_options] addopts = "-v --mypy -p no:warnings --cov=datahub --cov-report=html --doctest-modules --ignore=datahub/__main__.py" -[tool.ruff] -select = ["D", "E", "F", "I"] # pydocstyle, pycodestyle, Pyflakes, isort - -[tool.ruff.per-file-ignores] -"tests/*" = ["D100", "D104"] +[tool.ruff.lint] +select = [ + "D", # pydocstyle + "E", # pycodestyle + "F", # Pyflakes + "I", # isort + "UP", # pyupgrade + "RUF", # ruff +] +ignore = ["RUF012"] # Typing on mutable class attributes +pydocstyle.convention = "google" -[tool.ruff.pydocstyle] -convention = "google" +[tool.ruff.lint.per-file-ignores] +"tests/*" = [ + "D100", # Missing docstring in public module + "D104", # Missing docstring in public package +] diff --git a/tests/conftest.py b/tests/conftest.py index daba1c1..641bd15 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -55,7 +55,7 @@ def dsr_data_path(tmp_path): # Otherwise, create and write data to the file with h5py.File(file_path, "w") as h5file: for field in list(DSRModel.__fields__.values()): - if field.annotation == str: + if field.annotation is str: h5file[field.alias] = "Name or Warning" else: shape = field.field_info.extra["shape"] diff --git a/tests/test_opal.py b/tests/test_opal.py index e483cf9..0c7df68 100644 --- a/tests/test_opal.py +++ b/tests/test_opal.py @@ -16,8 +16,7 @@ def test_create_opal_frame(): assert np.issubdtype(df["Time"].dtype, np.datetime64) # Checks that all other data types are int or float - dtypes = df.dtypes - assert ((dtypes.drop("Time") == int) | (dtypes.drop("Time") == float)).all() + assert all(np.issubdtype(dtype, np.number) for dtype in df.dtypes.drop("Time")) def test_append_opal_data(opal_data): From b0363266f9851855c0d8b72e922dedb52c71775b Mon Sep 17 00:00:00 2001 From: Adrian D'Alessandro Date: Thu, 4 Jul 2024 17:03:08 +0100 Subject: [PATCH 3/3] Check automerge against PR owner, not github.actor --- .github/workflows/auto-merge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml index 3a3f7b2..d3dc86f 100644 --- a/.github/workflows/auto-merge.yml +++ b/.github/workflows/auto-merge.yml @@ -10,7 +10,7 @@ permissions: jobs: auto-merge: runs-on: ubuntu-latest - if: ${{ github.actor == 'dependabot[bot]' || github.actor == 'pre-commit-ci[bot]' }} + if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'pre-commit-ci[bot]' }} steps: - name: Enable auto-merge for Dependabot PRs run: |