forked from openslide/openslide
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.pre-commit-config.yaml
170 lines (158 loc) · 6.41 KB
/
.pre-commit-config.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# exclude vendored files
exclude: '^(COPYING\.LESSER|subprojects/.*)$'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
# We don't want to allow arbitrarily large binary diffs into the
# repo, where they'll live in the Git history forever. At the time
# of writing, our largest xdelta diff is 4881 bytes. Arbitrarily
# set the cutoff at 6000.
# https://openslide.org/docs/testsuite/#tips
- id: check-added-large-files
name: Check for overlarge tests
args: [--maxkb=6]
files: ^test/cases/
- id: check-added-large-files
args: [--maxkb=200]
- id: check-case-conflict
- id: check-merge-conflict
- id: check-toml
- id: check-vcs-permalinks
- id: check-yaml
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
hooks:
- id: pyupgrade
name: Modernize python code
exclude: ^misc/
args: ["--py38-plus"]
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
name: Reorder python imports with isort
exclude: ^misc/
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
name: Format python code with black
exclude: ^misc/
- repo: https://github.com/asottile/yesqa
rev: v1.5.0
hooks:
- id: yesqa
additional_dependencies: [flake8-bugbear, Flake8-pyproject]
exclude: ^misc/
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
name: Lint python code with flake8
additional_dependencies: [flake8-bugbear, Flake8-pyproject]
exclude: ^misc/
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
name: Check Python types
additional_dependencies:
- boto3-stubs[s3]
- pyfuse3
- types-PyYAML
- types-requests
exclude: ^misc/
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
- repo: local
hooks:
- id: meson-format
name: meson format
entry: meson format --configuration meson.format --inplace
types: [meson]
language: python
additional_dependencies: [meson==1.5.2]
- id: autoptr
name: Check for g_auto* declarations without initializers
language: pygrep
types: [c]
entry: "(g_auto\\(|g_autoptr\\(|g_autofree )(?!.+=)"
# Prevent use of dangerous or deprecated functions.
#
# Deprecated function Replacement
# atoi _openslide_parse_int64 or g_ascii_strtoll
# atol _openslide_parse_int64 or g_ascii_strtoll
# atoll _openslide_parse_int64 or g_ascii_strtoll
# calloc g_new0
# free g_free
# g_slice_alloc0 g_malloc0
# g_slice_alloc g_malloc
# g_slice_copy g_memdup
# g_slice_dup g_memdup
# g_slice_free1 g_free
# g_slice_free g_free
# g_slice_new0 g_new0
# g_slice_new g_new0
# malloc g_malloc
# realloc g_realloc
# stpcpy g_strdup
# strcat g_string_append
# strcpy g_strdup
# strdup g_strdup
# strerror g_strerror
# strerror_l g_strerror
# strndup g_strndup
# strtoimax _openslide_parse_int64 or g_ascii_strtoll
# strtol _openslide_parse_int64 or g_ascii_strtoll
# strtoll _openslide_parse_int64 or g_ascii_strtoll
# strtoul _openslide_parse_uint64 or g_ascii_strtoull
# strtoull _openslide_parse_uint64 or g_ascii_strtoull
# strtoumax _openslide_parse_uint64 or g_ascii_strtoull
- id: deny-prohibited
name: Check for calls to prohibited functions
language: pygrep
exclude: ^misc/
types: [c]
entry: "(^|\\W)(atoi|atol|atoll|calloc|free|g_slice_alloc0|g_slice_alloc|g_slice_copy|g_slice_dup|g_slice_free1|g_slice_free|g_slice_new0|g_slice_new|malloc|realloc|stpcpy|strcat|strcpy|strdup|strerror|strerror_l|strndup|strtoimax|strtol|strtoll|strtoul|strtoull|strtoumax)\\s*\\("
# Prevent use of functions with mandatory wrappers in OpenSlide.
# Wrapper implementations can add "// ci-allow" on the same line to
# skip the check.
#
# Deprecated function Replacement
# atof _openslide_parse_double
# fclose _openslide_fclose
# fopen _openslide_fopen
# fread _openslide_fread or _openslide_fread_exact
# fseeko _openslide_fseek
# fseek _openslide_fseek
# ftello _openslide_ftell
# ftell _openslide_ftell
# g_ascii_strtod _openslide_parse_double
# g_ascii_strtoll _openslide_parse_int64
# g_ascii_strtoull _openslide_parse_uint64
# g_file_test _openslide_fexists
# sqlite3_close _openslide_sqlite_close
# sqlite3_open _openslide_sqlite_open
# sqlite3_open_v2 _openslide_sqlite_open
# sscanf _openslide_parse_{double,int64,uint64}
# strtod _openslide_parse_double
# TIFFClientOpenExt _openslide_tiffcache_get
# TIFFClientOpen _openslide_tiffcache_get
# TIFFFdOpenExt _openslide_tiffcache_get
# TIFFFdOpen _openslide_tiffcache_get
# TIFFOpenExt _openslide_tiffcache_get
# TIFFOpen _openslide_tiffcache_get
# TIFFSetDirectory _openslide_tiff_set_dir
- id: deny-wrapped
name: Check for calls to wrapped functions
language: pygrep
files: ^src/openslide
types: [c]
entry: "(^|\\W)(atof|fclose|fopen|fread|fseeko|fseek|ftello|ftell|g_ascii_strtod|g_ascii_strtoll|g_ascii_strtoull|g_file_test|sqlite3_close|sqlite3_open|sqlite3_open_v2|sscanf|strtod|TIFFClientOpenExt|TIFFClientOpen|TIFFFdOpenExt|TIFFFdOpen|TIFFOpenExt|TIFFOpen|TIFFSetDirectory)\\s*\\((?!.+ci-allow)"