Skip to content

Commit 9eca901

Browse files
committed
Revamp pre-commit config to only built in hooks and local hooks
Run pre-commit using uv (it's in the lint group anyway) Drop Pre-commit Github Actions cache Add mypy pre-commit local repo hook Pin mypy to 1.19.1 (last to support Python 3.9) Try using uv to run mypy Use uv to run pre-commit... ...to run uv uv sync before running pre-commit Relock and add dependency cool down
1 parent 83a16c4 commit 9eca901

5 files changed

Lines changed: 751 additions & 40 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ on:
1313
types: [published]
1414

1515
jobs:
16-
format_type_check_lint_build_and_test:
16+
run_checks_build_and_test:
1717
# Builds and uploads wheel and sdist
1818
uses: ./.github/workflows/run_checks_build_and_test.yml
1919

2020
deploy:
2121
# Prevent deployment of releases that fail any tests or checks (e.g. linting).
22-
needs: format_type_check_lint_build_and_test
22+
needs: run_checks_build_and_test
2323
runs-on: ubuntu-latest
2424

2525
steps:

.github/workflows/run_checks_build_and_test.yml

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,47 +13,32 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v6
16-
- uses: actions/setup-python@v6
16+
17+
- name: Install the latest version of uv and set the python version
18+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
1719
with:
20+
version: 0.11.15 # uv version
1821
python-version: "3.14"
1922

20-
####################################################################
21-
# "this action is in maintenance-only mode and will not be accepting new features."
22-
# - uses: pre-commit/action@v3.0.1
23-
#
24-
# pre-commit/action does not intend to bump actions/cache from @v4:
25-
# https://github.com/pre-commit/action/issues/241
26-
# and has been stuck at @v3.0.1 for 2 years
27-
#
28-
# To bump actions/cache to v5 (to avoid the nuisance Node 20 deprecation
29-
# warning) the action is vendored below:
30-
#
31-
# Copyright (c) 2019 Anthony Sottile. MIT License.
32-
- run: python -m pip install pre-commit
33-
shell: bash
34-
- run: python -m pip freeze --local
35-
shell: bash
36-
- uses: actions/cache@v5
37-
with:
38-
path: ~/.cache/pre-commit
39-
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
40-
- run: pre-commit run --show-diff-on-failure --color=always ${{ inputs.extra_args }}
23+
- name: uv Sync project, asserting locked with dev dependency group
24+
run: uv sync --locked --group lint
25+
- run: uv run pre-commit run --all-files --show-diff-on-failure --color=always ${{ inputs.extra_args }}
4126
shell: bash
42-
#
43-
#
44-
#####################################################################
27+
4528

4629
mypy-strict:
4730
runs-on: ubuntu-latest
4831
steps:
4932
- uses: actions/checkout@v6
50-
- uses: actions/setup-python@v6
33+
- name: Install the latest version of uv and set the python version
34+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
5135
with:
52-
python-version: "3.13"
53-
- name: Install mypy
54-
run: pip install mypy
36+
version: 0.11.15 # uv version
37+
python-version: "3.14"
38+
39+
# use latest mypy version here, (even though pinned to 1.19.1 in lint group for Python 3.9 support)
5540
- name: Run mypy --strict
56-
run: mypy --strict ./src/shapefile.py
41+
run: uvx mypy --strict ./src/shapefile.py
5742

5843

5944
build_wheel_and_sdist:

.pre-commit-config.yaml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
11
repos:
2-
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.15.13
2+
- repo: local
43
hooks:
5-
# Run the linter
64
- id: ruff-check
7-
args: [ --fix ]
8-
# Run the formatter
5+
name: ruff check
6+
entry: uv run ruff check
7+
language: system
8+
pass_filenames: false
99
- id: ruff-format
10+
name: ruff format
11+
entry: uv run ruff format
12+
language: system
13+
pass_filenames: false
14+
- id: mypy
15+
name: mypy
16+
entry: uv run mypy --strict .
17+
language: system
18+
pass_filenames: false
19+
# - repo: https://github.com/astral-sh/ruff-pre-commit
20+
# rev: v0.15.13
21+
# hooks:
22+
# # Run the linter
23+
# - id: ruff-check
24+
# args: [ --fix ]
25+
# # Run the formatter
26+
# - id: ruff-format
1027
- repo: https://github.com/pre-commit/pre-commit-hooks
1128
rev: v6.0.0
1229
hooks:
1330
- id: check-yaml
1431
- id: trailing-whitespace
32+

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dev = [
3737
{include-group = "test"}
3838
]
3939
lint = [
40-
"mypy>=2.1.0",
40+
"mypy==1.19.1", # last to support Python 3.9
4141
"pre-commit",
4242
"ruff",
4343
]
@@ -48,14 +48,16 @@ test = [
4848
[project.urls]
4949
Repository = "https://github.com/GeospatialPython/pyshp"
5050

51-
51+
[tool.uv]
52+
exclude-newer = "1 week"
53+
exclude-newer-package = {pyshp = false, pyshp-stubs = false}
5254

5355
[tool.mypy]
5456
files=["src/shapefile.py"]
5557
mypy_path = "src"
5658
explicit_package_bases = true
5759
exclude_gitignore = true
58-
exclude=[
60+
exclude=[ # Mypy requires regexes, not globs:
5961
'test_shapefile\.py',
6062
'run_benchmarks\.py',
6163
]

0 commit comments

Comments
 (0)