Skip to content

Commit c2ec075

Browse files
committed
add checks and exceptions
1 parent dafcb5e commit c2ec075

File tree

16 files changed

+252
-52
lines changed

16 files changed

+252
-52
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ ignore =
2323
W503,
2424
# W504: line break after binary operator
2525
W504
26-
exclude =
26+
exclude =
2727
.eggs
2828
build

.github/ISSUE_TEMPLATE/bug-report.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ assignees: ''
1313
## How To Reproduce
1414
Steps to reproduce the behaviour:
1515

16-
1.
17-
2.
18-
3.
16+
1.
17+
2.
18+
3.
1919

2020
## Expected behaviour
2121
<!-- A clear and concise description of what you expected to happen -->
2222

2323
## Screenshots
2424
<!-- If applicable, add screenshots to help explain your problem -->
2525

26-
## Environment
26+
## Environment
2727
- OS & Version: [e.g., Ubuntu 20.04 LTS]
2828
- Stratify Version
2929

.github/workflows/ci-wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
- name: "Building sdist"
7777
shell: bash
7878
run: |
79-
pipx run build --sdist
79+
pipx run build --sdist
8080
8181
- uses: actions/upload-artifact@v4
8282
with:

.github/workflows/stale.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
Otherwise this issue will be automatically closed in ${{ env.DAYS_BEFORE_CLOSE }} days time.
3939
4040
# Comment on the staled prs.
41-
stale-pr-message: |
41+
stale-pr-message: |
4242
In order to maintain a backlog of relevant PRs, we automatically label them as stale after ${{ env.DAYS_BEFORE_STALE }} days of inactivity.
4343
4444
If this PR is still important to you, then please comment on this PR and the stale label will be removed.
@@ -48,15 +48,15 @@ jobs:
4848
# Comment on the staled issues while closed.
4949
close-issue-message: |
5050
This stale issue has been automatically closed due to a lack of community activity.
51-
51+
5252
If you still care about this issue, then please either:
5353
* Re-open this issue, if you have sufficient permissions, or
5454
* Add a comment pinging `@SciTools/stratify-maintainers` who will re-open on your behalf.
5555
5656
# Comment on the staled prs while closed.
5757
close-pr-message: |
5858
This stale PR has been automatically closed due to a lack of community activity.
59-
59+
6060
If you still care about this PR, then please either:
6161
* Re-open this PR, if you have sufficient permissions, or
6262
* Add a comment pinging `@SciTools/stratify-maintainers` who will re-open on your behalf.
@@ -85,4 +85,4 @@ jobs:
8585
ascending: true
8686

8787
# Exempt all issues/prs with milestones from stale.
88-
exempt-all-milestones: true
88+
exempt-all-milestones: true

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,4 @@ dmypy.json
133133
.pyre/
134134

135135
# PyCharm
136-
.idea
136+
.idea

.pre-commit-config.yaml

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33

44
ci:
5-
autoupdate_commit_msg: "chore: update pre-commit hooks"
5+
autofix_prs: false
6+
autoupdate_commit_msg: "chore: update pre-commit hooks"
67

78
repos:
89
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -18,27 +19,43 @@ repos:
1819
- id: check-merge-conflict
1920
# Check for debugger imports and py37+ `breakpoint()` calls in Python source.
2021
- id: debug-statements
22+
# Check TOML file syntax.
23+
- id: check-toml
24+
# Check YAML file syntax.
25+
- id: check-yaml
26+
# Makes sure files end in a newline and only a newline.
27+
# Duplicates Ruff W292 but also works on non-Python files.
28+
- id: end-of-file-fixer
29+
# Replaces or checks mixed line ending.
30+
- id: mixed-line-ending
2131
# Don't commit to master branch.
2232
- id: no-commit-to-branch
23-
- repo: https://github.com/psf/black-pre-commit-mirror
24-
rev: '24.10.0'
33+
# Trims trailing whitespace.
34+
# Duplicates Ruff W291 but also works on non-Python files.
35+
- id: trailing-whitespace
36+
37+
38+
- repo: https://github.com/astral-sh/ruff-pre-commit
39+
rev: "v0.7.3"
2540
hooks:
26-
- id: black
41+
- id: ruff
42+
types: [file, python]
43+
args: [--fix, --show-fixes]
44+
- id: ruff-format
2745
types: [file, python]
28-
args: [--config=./pyproject.toml, .]
29-
- repo: https://github.com/PyCQA/flake8
30-
rev: '7.1.1'
46+
47+
- repo: https://github.com/codespell-project/codespell
48+
rev: "v2.3.0"
3149
hooks:
32-
# Run flake8.
33-
- id: flake8
34-
args: [--config=./.flake8]
50+
- id: codespell
51+
types_or: [asciidoc, python, markdown, rst]
52+
additional_dependencies: [tomli]
53+
54+
55+
3556
- repo: https://github.com/pycqa/isort
3657
rev: '5.13.2'
3758
hooks:
38-
- id: isort
39-
name: isort (python)
40-
types: [file, python]
41-
args: [--filter-files]
4259
- id: isort
4360
name: isort (cython)
4461
types: [file, cython]
@@ -49,3 +66,28 @@ repos:
4966
hooks:
5067
- id: sort-all
5168
types: [file, python]
69+
70+
- repo: https://github.com/pre-commit/mirrors-mypy
71+
rev: 'v1.13.0'
72+
hooks:
73+
- id: mypy
74+
exclude: 'noxfile\.py|docs/conf\.py'
75+
76+
- repo: https://github.com/abravalheri/validate-pyproject
77+
# More exhaustive than Ruff RUF200.
78+
rev: "v0.23"
79+
hooks:
80+
- id: validate-pyproject
81+
82+
- repo: https://github.com/scientific-python/cookie
83+
rev: 2024.08.19
84+
hooks:
85+
- id: sp-repo-review
86+
additional_dependencies: ["repo-review[cli]"]
87+
args: ["--show=errskip"]
88+
89+
- repo: https://github.com/numpy/numpydoc
90+
rev: v1.8.0
91+
hooks:
92+
- id: numpydoc-validation
93+
types: [file, python]

LICENSE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
BSD 3-Clause License
2-
Copyright (c) 2015 - 2017, Met Office.
2+
Copyright (c) 2015 - 2017, Met Office.
33
All rights reserved.
44

55
Redistribution and use in source and binary forms, with or without
@@ -26,4 +26,3 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
2626
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2727
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2828
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,3 @@ pip install stratify
3333

3434
## License
3535
Stratify is licenced under a [BSD 3-Clause License](LICENSE).
36-

pyproject.toml

Lines changed: 170 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ where = ["src"]
6868
write_to = "src/stratify/_version.py"
6969
local_scheme = "dirty-tag"
7070

71-
[tool.black]
72-
target-version = ["py310", "py311", "py312"]
73-
line-length = 88
74-
include = '\.pyi?$'
71+
#[tool.black]
72+
#target-version = ["py310", "py311", "py312"]
73+
#line-length = 88
74+
#include = '\.pyi?$'
7575

7676
[tool.isort]
7777
profile = "black"
@@ -88,3 +88,169 @@ ignore = [
8888
[tool.pytest.ini_options]
8989
addopts = "-ra -v --doctest-modules"
9090
testpaths = ["src/stratify"]
91+
92+
[tool.mypy]
93+
disable_error_code = ["call-arg", "no-untyped-def", "no-untyped-call", "attr-defined", "misc", "index", "var-annotated", "assignment"]
94+
enable_error_code = ["ignore-without-code", "truthy-bool", "redundant-expr"]
95+
warn_unreachable = true
96+
strict = true
97+
# exclude = [
98+
# No common agreement yet
99+
# NOTE: these exclusions must also appear in pre-commit-config.yaml.
100+
# https://stackoverflow.com/questions/77350979/running-pre-commits-excluding-a-directory-for-multiples-hooks/77352664#77352664
101+
# ]
102+
# NOTE: Non-permanent disabling should be done via the ".mypy.ini" file.
103+
# disable_error_code = No common agreement yet
104+
105+
[tool.numpydoc_validation]
106+
checks = [
107+
"all", # Enable all numpydoc validation rules, apart from the following:
108+
109+
# -> Docstring text (summary) should start in the line immediately
110+
# after the opening quotes (not in the same line, or leaving a
111+
# blank line in between)
112+
"GL01", # Permit summary line on same line as docstring opening quotes.
113+
114+
# -> Closing quotes should be placed in the line after the last text
115+
# in the docstring (do not close the quotes in the same line as
116+
# the text, or leave a blank line between the last text and the
117+
# quotes)
118+
"GL02", # Permit a blank line before docstring closing quotes.
119+
120+
# -> Double line break found; please use only one blank line to
121+
# separate sections or paragraphs, and do not leave blank lines
122+
# at the end of docstrings
123+
"GL03", # Ignoring.
124+
125+
"GL08",
126+
127+
"PR01",
128+
"PR02",
129+
"PR10",
130+
"RT04",
131+
"SS06",
132+
133+
134+
# -> See Also section not found
135+
"SA01", # Not all docstrings require a "See Also" section.
136+
137+
# -> No extended summary found
138+
"ES01", # Not all docstrings require an "Extended Summary" section.
139+
140+
# -> No examples section found
141+
"EX01", # Not all docstrings require an "Examples" section.
142+
143+
# -> No Yields section found
144+
"YD01", # Not all docstrings require a "Yields" section.
145+
146+
# Record temporarily ignored checks below; will be reviewed at a later date:
147+
148+
]
149+
exclude = [
150+
'\.__eq__$',
151+
'\.__ne__$',
152+
'\.__repr__$',
153+
]
154+
155+
[tool.ruff]
156+
line-length = 88
157+
158+
[tool.ruff.format]
159+
preview = false
160+
161+
[tool.ruff.lint]
162+
ignore = [
163+
# NOTE: Non-permanent exclusions should be added to the ".ruff.toml" file.
164+
"ERA001",
165+
"RUF005",
166+
"D100",
167+
"B028",
168+
"D101",
169+
"RUF012",
170+
"ANN201",
171+
"D102",
172+
"T201",
173+
"C419",
174+
"D104",
175+
"D106",
176+
"ANN202",
177+
"SLF001",
178+
"N801",
179+
"D205",
180+
"PT009",
181+
"PT027",
182+
"ANN001",
183+
"ARG002",
184+
"ARG003",
185+
"ANN002",
186+
"ANN204",
187+
"D103",
188+
"FBT002",
189+
"ANN003",
190+
"RET504",
191+
"C405",
192+
"PLR2004",
193+
194+
195+
# flake8-commas (COM)
196+
# https://docs.astral.sh/ruff/rules/#flake8-commas-com
197+
"COM812", # Trailing comma missing.
198+
"COM819", # Trailing comma prohibited.
199+
200+
# flake8-implicit-str-concat (ISC)
201+
# https://docs.astral.sh/ruff/rules/single-line-implicit-string-concatenation/
202+
# NOTE: This rule may cause conflicts when used with "ruff format".
203+
"ISC001", # Implicitly concatenate string literals on one line.
204+
]
205+
preview = false
206+
select = [
207+
"ALL",
208+
# list specific rules to include that is skipped using numpy convention.
209+
"D212", # Multi-line docstring summary should start at the first line
210+
]
211+
212+
[tool.ruff.lint.isort]
213+
force-sort-within-sections = true
214+
# Change to match specific package name:
215+
known-first-party = ["iris"]
216+
217+
[tool.ruff.lint.per-file-ignores]
218+
# All test scripts
219+
220+
# Change to match specific package path:
221+
"lib/iris/tests/*.py" = [
222+
# https://docs.astral.sh/ruff/rules/undocumented-public-module/
223+
"D100", # Missing docstring in public module
224+
"D205", # 1 blank line required between summary line and description
225+
"D401", # 1 First line of docstring should be in imperative mood
226+
]
227+
228+
[tool.ruff.lint.pydocstyle]
229+
convention = "numpy"
230+
231+
[tool.codespell]
232+
ignore-words-list = "ND,Nd"
233+
234+
[tool.repo-review]
235+
# These are a list of the currently failing tests to be fixed later:
236+
ignore = [
237+
"PY004", # Has docs folder
238+
"PP302", # Sets a minimum pytest to at least 6
239+
"PP304", # Sets the log level in pytest
240+
"PP305", # Specifies xfail_strict
241+
"PP306", # Specifies strict config
242+
"PP307", # Specifies strict markers
243+
"PP308",
244+
"PP309", # Filter warnings specified
245+
"PY007", # Supports an easy task runner (nox or tox)
246+
"PP003", # Does not list wheel as a build-dep
247+
"PC111", # Uses blacken-docs
248+
"PC140", # Uses a type checker
249+
"PC160", # Uses a spell checker
250+
"PC170", # Uses PyGrep hooks (only needed if rST present)
251+
"PC180", # Uses a markdown formatter
252+
"PC190", # Uses Ruff
253+
"MY100", # Uses MyPy (pyproject config)
254+
"RF001", # Has Ruff config
255+
"RTD100" # Uses ReadTheDocs (pyproject config)
256+
]

requirements/pypi-core.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Cython
22
dask[array]
3-
numpy==1.26.4
3+
numpy==1.26.4

0 commit comments

Comments
 (0)