From 9b2272bcad90f2a42b8d4acfa6d91794a11b644c Mon Sep 17 00:00:00 2001 From: Ben Jeffery Date: Tue, 9 Sep 2025 10:28:57 +0100 Subject: [PATCH 1/2] Use reusable lint workflow --- .github/workflows/tests.yml | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d5d16177b..1bbee759d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,24 +3,13 @@ name: Tests on: pull_request: push: - branches: [main] + branches: [main, test] merge_group: jobs: pre-commit: name: Lint - runs-on: ubuntu-24.04 - steps: - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.12.1 - with: - access_token: ${{ github.token }} - - uses: actions/checkout@v4.2.2 - - uses: actions/setup-python@v5.4.0 - - name: install clang-format - run: | - pip install clang-format==6.0.1 - - uses: pre-commit/action@v3.0.1 + uses: tskit-dev/.github/.github/workflows/lint.yml@v1 test: name: Python From 42133925391ee262e8da058a27ceef1798da4cfd Mon Sep 17 00:00:00 2001 From: Ben Jeffery Date: Tue, 9 Sep 2025 12:42:48 +0100 Subject: [PATCH 2/2] Update pre-commit hooks and fix linting issues --- .github/workflows/tests.yml | 2 +- .pre-commit-config.yaml | 8 ++++---- lib/util.c | 2 +- msprime/core.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1bbee759d..d09b2fb1c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,7 +9,7 @@ on: jobs: pre-commit: name: Lint - uses: tskit-dev/.github/.github/workflows/lint.yml@v1 + uses: tskit-dev/.github/.github/workflows/lint.yml@v2 test: name: Python diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a324185f8..cbafa1879 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: - id: check-merge-conflict - id: debug-statements @@ -14,12 +14,12 @@ repos: exclude: argtable3 verbose: true - repo: https://github.com/asottile/reorder_python_imports - rev: v3.14.0 + rev: v3.15.0 hooks: - id: reorder-python-imports args: [--unclassifiable-application-module=_msprime] - repo: https://github.com/asottile/pyupgrade - rev: v3.19.1 + rev: v3.20.0 hooks: - id: pyupgrade args: [--py38-plus] @@ -29,7 +29,7 @@ repos: - id: black language_version: python3 - repo: https://github.com/pycqa/flake8 - rev: 7.1.2 + rev: 7.3.0 hooks: - id: flake8 args: [--config=.flake8] diff --git a/lib/util.c b/lib/util.c index 270201fea..196c5340f 100644 --- a/lib/util.c +++ b/lib/util.c @@ -676,7 +676,7 @@ fast_search_alloc(fast_search_t *self, const double *elements, size_t n_elements * of the array. The rest of the lookup element indexes point to (max_element * * query_multiplier) non-zero element values. */ - self->num_lookups = 2 + (size_t) (max_element * self->query_multiplier); + self->num_lookups = 2 + (size_t)(max_element * self->query_multiplier); self->query_cutoff = ((double) self->num_lookups - 1) / self->query_multiplier; diff --git a/msprime/core.py b/msprime/core.py index 9569d807c..7f68774bc 100644 --- a/msprime/core.py +++ b/msprime/core.py @@ -69,7 +69,7 @@ def clear_seed_rng(): def get_random_seed() -> int: - global _seed_rng_map + global _seed_rng_map # noqa: F824 pid = os.getpid() if pid not in _seed_rng_map: # If we don't provide a seed to Random(), Python will seed either @@ -87,7 +87,7 @@ def set_seed_rng_seed(seed: int): DO NOT USE THIS FUNCTION!!! """ - global _seed_rng_map + global _seed_rng_map # noqa: F824 pid = os.getpid() _seed_rng_map[pid] = random.Random(seed)