From ca7ce749e00dbde1c577e6c9a195e56be7f596f0 Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Wed, 12 Feb 2025 13:13:49 -0500 Subject: [PATCH 1/3] update precommit --- .pre-commit-config.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index da4729b..a4dcb18 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,6 +9,8 @@ repos: - id: check-merge-conflict - id: detect-aws-credentials args: [ --allow-missing-credentials ] + - id: mixed-line-ending + args: [ --fix=lf ] - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.5.0 # ruff version hooks: @@ -22,4 +24,4 @@ repos: entry: bash -c 'cd rust && cargo fmt' args: ['--verbose', '--'] -minimum_pre_commit_version: 3.7.1 +minimum_pre_commit_version: 4.0.1 From 3a1330a6d397fd9e0a6a4b0fdb4dd41afff6de21 Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Wed, 12 Feb 2025 13:14:54 -0500 Subject: [PATCH 2/3] style updates --- .github/workflows/checks.yaml | 20 +++++++++++++- .pre-commit-config.yaml | 2 +- pyproject.toml | 52 ++++++++++++----------------------- src/vrsix/load.py | 6 ++-- tests/test_load.py | 2 +- 5 files changed, 41 insertions(+), 41 deletions(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 733a7eb..0a0368c 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -33,7 +33,7 @@ jobs: run: python3 -m pip install ".[dev]" - name: Check style - run: python3 -m ruff check . && ruff format --check . + run: python3 -m ruff check . && python3 -m ruff format --check . rust-test: runs-on: ubuntu-latest defaults: @@ -62,3 +62,21 @@ jobs: run: rustup component add rustfmt - run: cargo fmt -- --check + precommit_hooks: + runs-on: ubuntu-latest + strategy: + matrix: + - cmd: "end-of-file-fixer" + - cmd: "trailing-whitespace" + - cmd: "mixed-line-ending" + steps: + - uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: 3.12 + + - uses: pre-commit/action@v3.0.1 + with: + extra_args: ${{ matrix.cmd }} --all-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a4dcb18..1b736b7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: mixed-line-ending args: [ --fix=lf ] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.0 # ruff version + rev: v0.8.6 # ruff version hooks: - id: ruff-format - id: ruff diff --git a/pyproject.toml b/pyproject.toml index 12dfb43..d3abf44 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,8 +30,8 @@ tests = [ ] dev = [ "maturin", - "ruff==0.5.0", - "pre-commit>=3.7.1", + "ruff==0.8.6", + "pre-commit>=4.0.1", ] [project.urls] @@ -94,6 +94,9 @@ select = [ "ARG", # https://docs.astral.sh/ruff/rules/#flake8-unused-arguments-arg "PTH", # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth "PGH", # https://docs.astral.sh/ruff/rules/#pygrep-hooks-pgh + "PLC", # https://docs.astral.sh/ruff/rules/#convention-c + "PLE", # https://docs.astral.sh/ruff/rules/#error-e_1 + "TRY", # https://docs.astral.sh/ruff/rules/#tryceratops-try "PERF", # https://docs.astral.sh/ruff/rules/#perflint-perf "FURB", # https://docs.astral.sh/ruff/rules/#refurb-furb "RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf @@ -112,51 +115,27 @@ fixable = [ "PT", "RSE", "SIM", + "PLC", + "PLE", + "TRY", "PERF", "FURB", "RUF" ] -# ANN003 - missing-type-kwargs -# ANN101 - missing-type-self -# ANN102 - missing-type-cls -# D203 - one-blank-line-before-class -# D205 - blank-line-after-summary -# D206 - indent-with-spaces* -# D213 - multi-line-summary-second-line -# D300 - triple-single-quotes* -# D400 - ends-in-period -# D415 - ends-in-punctuation -# E111 - indentation-with-invalid-multiple* -# E114 - indentation-with-invalid-multiple-comment* -# E117 - over-indented* -# E501 - line-too-long* -# W191 - tab-indentation* -# S321 - suspicious-ftp-lib-usage -# *ignored for compatibility with formatter ignore = [ - "ANN003", "ANN101", "ANN102", - "D203", "D205", "D206", "D213", "D300", "D400", "D415", - "E111", "E114", "E117", "E501", - "W191", + # ignored for compatibility with formatter: + "D206", "D300", "E111", "E114", "E117", "E501", "W191", + # other + "ANN003", + "D203", "D205", "D213", "D400", "D415", "S321", + "PLC0206", ] [tool.ruff.lint.per-file-ignores] -# ANN001 - missing-type-function-argument -# ANN2 - missing-return-type -# ANN102 - missing-type-cls -# D301 - escape-sequence-in-docstring -# S101 - assert -# B011 - assert-false -# D100 - undocumented-public-module -# D101 - undocumented-public-class -# D102 - undocumented-public-method -# D103 - undocumented-public-function -# INP001 - implicit-namespace-package "tests/*" = [ "ANN001", "ANN2", - "ANN102", "S101", "B011", "INP001", @@ -167,5 +146,8 @@ ignore = [ ] "src/vrsix/cli.py" = ["D301"] +[tool.ruff.lint.flake8-annotations] +mypy-init-return = true + [tool.ruff.format] docstring-code-format = true diff --git a/src/vrsix/load.py b/src/vrsix/load.py index 3532ce8..c72658d 100644 --- a/src/vrsix/load.py +++ b/src/vrsix/load.py @@ -14,13 +14,13 @@ from vrsix.sqlite import DEFAULT_SQLITE_LOCATION __all__ = [ - "load_vcf", - "vcf_to_sqlite", "FiletypeError", "SqliteFileError", - "VrsixError", "VcfError", "VrsixDbError", + "VrsixError", + "load_vcf", + "vcf_to_sqlite", ] _logger = logging.getLogger(__name__) diff --git a/tests/test_load.py b/tests/test_load.py index 32737cc..b54ff22 100644 --- a/tests/test_load.py +++ b/tests/test_load.py @@ -8,7 +8,7 @@ from vrsix import load -@pytest.fixture() +@pytest.fixture def temp_dir() -> Generator: with tempfile.TemporaryDirectory() as temp_dir: yield Path(temp_dir) From f7a20f902f4c1fc9816bbf7e4ec6850518ac0f80 Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Wed, 12 Feb 2025 13:16:00 -0500 Subject: [PATCH 3/3] fix workflow --- .github/workflows/checks.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 0a0368c..428db2c 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -66,9 +66,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - - cmd: "end-of-file-fixer" - - cmd: "trailing-whitespace" - - cmd: "mixed-line-ending" + cmd: + - "end-of-file-fixer" + - "trailing-whitespace" + - "mixed-line-ending" steps: - uses: actions/checkout@v4