Skip to content

Commit 3066d34

Browse files
committed
feat:pre-commit Added pre-commit file and added to Python CI
1 parent b565ccf commit 3066d34

File tree

5 files changed

+82
-9
lines changed

5 files changed

+82
-9
lines changed

.github/workflows/test-python.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,30 @@ on:
77
pull_request:
88

99
jobs:
10+
pre-commit:
11+
name: Pre-Commit
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.11"
19+
20+
# Use ruff-action so we get annotations in the Github UI
21+
- uses: astral-sh/ruff-action@v3
22+
23+
- name: Cache pre-commit virtualenvs
24+
uses: actions/cache@v4
25+
with:
26+
path: ~/.cache/pre-commit
27+
key: pre-commit-3|${{ hashFiles('.pre-commit-config.yaml') }}
28+
29+
- name: run pre-commit
30+
run: |
31+
python -m pip install pre-commit
32+
pre-commit run --all-files
33+
1034
lint-test:
1135
name: Lint and Test
1236
runs-on: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
4+
# Default to Python 3
5+
default_language_version:
6+
python: python3
7+
8+
# Optionally both commit and push
9+
default_stages: [pre-commit]
10+
11+
repos:
12+
- repo: https://github.com/pre-commit/pre-commit-hooks
13+
rev: v5.0.0
14+
hooks:
15+
- id: trailing-whitespace
16+
- id: end-of-file-fixer
17+
- id: check-added-large-files
18+
args: ["--maxkb=500"]
19+
20+
- repo: https://github.com/astral-sh/ruff-pre-commit
21+
rev: v0.11.0
22+
hooks:
23+
- id: ruff
24+
args: ["--fix"]
25+
- id: ruff-format
26+
27+
- repo: local
28+
hooks:
29+
- id: rust-fmt
30+
name: cargo fmt
31+
entry: cargo fmt --all -- --check
32+
language: system
33+
types: [rust]
34+
stages: [pre-push]
35+
36+
- id: rust-clippy
37+
name: cargo clippy
38+
entry: cargo clippy --all --all-features --tests -- -D warnings
39+
language: system
40+
types: [rust]
41+
stages: [pre-push]
42+
pass_filenames: false
43+
44+
- id: rust-test
45+
name: cargo test
46+
entry: cargo test --all --all-features
47+
language: system
48+
types: [rust]
49+
stages: [pre-push]
50+
pass_filenames: false

python/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,3 @@ primary_ifd.bits_per_sample[0]
8383
tile = await tiff.fetch_tile(0, 0, 0)
8484
decoded_bytes = await tile.decode_async()
8585
```
86-

python/python/async_tiff/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from typing import TYPE_CHECKING
22

3-
from ._async_tiff import *
3+
from ._async_tiff import * # noqa: F403
44
from ._async_tiff import ___version
55

66
if TYPE_CHECKING:
7-
from . import store
7+
from . import store # noqa: F401
88

99
__version__: str = ___version()

tests/image_tiff/images/COPYRIGHT

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
Copyright (c) 1988-1997 Sam Leffler
22
Copyright (c) 1991-1997 Silicon Graphics, Inc.
33

4-
Permission to use, copy, modify, distribute, and sell this software and
4+
Permission to use, copy, modify, distribute, and sell this software and
55
its documentation for any purpose is hereby granted without fee, provided
66
that (i) the above copyright notices and this permission notice appear in
77
all copies of the software and related documentation, and (ii) the names of
88
Sam Leffler and Silicon Graphics may not be used in any advertising or
99
publicity relating to the software without the specific, prior written
1010
permission of Sam Leffler and Silicon Graphics.
1111

12-
THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
13-
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
14-
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
12+
THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
13+
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
14+
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
1515

1616
IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
1717
ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
1818
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
19-
WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
20-
LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
19+
WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
20+
LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
2121
OF THIS SOFTWARE.

0 commit comments

Comments
 (0)