Skip to content

Commit cc884a7

Browse files
authored
Merge pull request #135 from nikosavola/pre-commit-fixes
Pre-commit fixes
2 parents 1578eb8 + 8628c0f commit cc884a7

File tree

5 files changed

+101
-94
lines changed

5 files changed

+101
-94
lines changed

.pre-commit-config.yaml

Lines changed: 89 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repos:
1313
- id: name-tests-test
1414
args: ["--pytest-test-first"]
1515
- id: trailing-whitespace
16-
exclude: "tests/references/*"
16+
exclude: "tests/references/.*"
1717

1818
# - repo: https://github.com/hakancelik96/unimport
1919
# rev: 0.14.1
@@ -49,96 +49,97 @@ repos:
4949
- id: pyupgrade
5050
args: [--py37-plus, --keep-runtime-typing]
5151

52-
# - repo: https://github.com/codespell-project/codespell
53-
# rev: 68ea3cff5eba266e0814794cce6cd19537f58137
54-
# hooks:
55-
# - id: codespell
56-
# args: ["-L TE,TE/TM,te,ba,FPR,fpr_spacing,ro,donot"]
52+
# - repo: https://github.com/codespell-project/codespell
53+
# rev: 68ea3cff5eba266e0814794cce6cd19537f58137
54+
# hooks:
55+
# - id: codespell
56+
# args: ["-L TE,TE/TM,te,ba,FPR,fpr_spacing,ro,donot"]
5757

58-
# - repo: https://github.com/shellcheck-py/shellcheck-py
59-
# rev: 953faa6870f6663ac0121ab4a800f1ce76bca31f
60-
# hooks:
61-
# - id: shellcheck
58+
# - repo: https://github.com/shellcheck-py/shellcheck-py
59+
# rev: 953faa6870f6663ac0121ab4a800f1ce76bca31f
60+
# hooks:
61+
# - id: shellcheck
6262

63-
# - repo: https://github.com/pre-commit/pygrep-hooks
64-
# rev: 7b4409161486c6956bb3206ce96db5d56731b1b9 # Use the ref you want to point at
65-
# hooks:
66-
# - id: python-use-type-annotations
63+
# - repo: https://github.com/pre-commit/pygrep-hooks
64+
# rev: 7b4409161486c6956bb3206ce96db5d56731b1b9 # Use the ref you want to point at
65+
# hooks:
66+
# - id: python-use-type-annotations
6767

68-
# - repo: https://github.com/PyCQA/bandit
69-
# rev: fe1361fdcc274850d4099885a802f2c9f28aca08
70-
# hooks:
71-
# - id: bandit
72-
# args: [--exit-zero]
73-
# # ignore all tests, not just tests data
74-
# exclude: ^tests/
75-
# - repo: https://github.com/pre-commit/mirrors-mypy
76-
# rev: "v1.0.1"
77-
# hooks:
78-
# - id: mypy
79-
# exclude: ^(docs/|example-plugin/|tests/fixtures)
80-
# additional_dependencies:
81-
# - "pydantic"
82-
# - repo: https://github.com/terrencepreilly/darglint
83-
# rev: master
84-
# hooks:
85-
# - id: darglint
86-
# - repo: https://github.com/pycqa/pydocstyle
87-
# rev: "a6fe4222012e990042c86cdaaa904a8d059752ee"
88-
# hooks:
89-
# - id: pydocstyle
90-
# additional_dependencies: ["pydocstyle[toml]"]
91-
# - repo: https://github.com/asottile/reorder_python_imports
92-
# rev: 2b2f0c74acdb3de316e23ceb7dd0d7945c354050
93-
# hooks:
94-
# - id: reorder-python-imports
95-
# - repo: https://github.com/PyCQA/pylint
96-
# rev: v2.14.1
97-
# hooks:
98-
# - id: pylint
99-
# args: [--exit-zero]
100-
# - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
101-
# rev: 6565d773ca281682d7062d4c0be74538cc474cc9
102-
# hooks:
103-
# - id: pretty-format-java
104-
# args: [--autofix]
105-
# - id: pretty-format-kotlin
106-
# args: [--autofix]
107-
# - id: pretty-format-yaml
108-
# args: [--autofix, --indent, "2"]
109-
# - repo: https://github.com/adrienverge/yamllint.git
110-
# rev: v1.21.0 # or higher tag
111-
# hooks:
112-
# - id: yamllint
113-
# args: [--format, parsable, --strict]
114-
# - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
115-
# rev: 0.1.0 # or specific tag
116-
# hooks:
117-
# - id: yamlfmt
118-
# - repo: https://github.com/pre-commit/pygrep-hooks
119-
# rev: "f6fb13e9516d1a9720a30a4049c930235abd642e"
120-
# hooks:
121-
# - id: python-check-blanket-noqa
122-
# - id: python-check-blanket-type-ignore
123-
# - id: python-no-log-warn
124-
# - id: python-no-eval
125-
# - id: python-use-type-annotations
126-
# - id: rst-backticks
127-
# - id: rst-directive-colons
128-
# - id: rst-inline-touching-normal
129-
# - repo: https://github.com/nbQA-dev/nbQA
130-
# rev: 952c895a21aced4601165c43f77188559a5e825c
131-
# hooks:
132-
# - id: nbqa-black
133-
# additional_dependencies: [jupytext, black] # optional, only if you're using Jupytext
134-
# - id: nbqa-pyupgrade
135-
# args: ["--py37-plus"]
136-
# - id: nbqa-flake8
137-
# - id: nbqa-isort
138-
# args: ["--float-to-top"]
139-
- repo: https://github.com/charliermarsh/ruff-pre-commit
140-
rev: "6a0ba1854991b693612486cc84a2254de82d071d"
68+
# - repo: https://github.com/PyCQA/bandit
69+
# rev: fe1361fdcc274850d4099885a802f2c9f28aca08
70+
# hooks:
71+
# - id: bandit
72+
# args: [--exit-zero]
73+
# # ignore all tests, not just tests data
74+
# exclude: ^tests/
75+
# - repo: https://github.com/pre-commit/mirrors-mypy
76+
# rev: "v1.0.1"
77+
# hooks:
78+
# - id: mypy
79+
# exclude: ^(docs/|example-plugin/|tests/fixtures)
80+
# additional_dependencies:
81+
# - "pydantic"
82+
# - repo: https://github.com/terrencepreilly/darglint
83+
# rev: master
84+
# hooks:
85+
# - id: darglint
86+
# - repo: https://github.com/pycqa/pydocstyle
87+
# rev: "a6fe4222012e990042c86cdaaa904a8d059752ee"
88+
# hooks:
89+
# - id: pydocstyle
90+
# additional_dependencies: ["pydocstyle[toml]"]
91+
# - repo: https://github.com/asottile/reorder_python_imports
92+
# rev: 2b2f0c74acdb3de316e23ceb7dd0d7945c354050
93+
# hooks:
94+
# - id: reorder-python-imports
95+
# - repo: https://github.com/PyCQA/pylint
96+
# rev: v2.14.1
97+
# hooks:
98+
# - id: pylint
99+
# args: [--exit-zero]
100+
# - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
101+
# rev: 6565d773ca281682d7062d4c0be74538cc474cc9
102+
# hooks:
103+
# - id: pretty-format-java
104+
# args: [--autofix]
105+
# - id: pretty-format-kotlin
106+
# args: [--autofix]
107+
# - id: pretty-format-yaml
108+
# args: [--autofix, --indent, "2"]
109+
# - repo: https://github.com/adrienverge/yamllint.git
110+
# rev: v1.21.0 # or higher tag
111+
# hooks:
112+
# - id: yamllint
113+
# args: [--format, parsable, --strict]
114+
# - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
115+
# rev: 0.1.0 # or specific tag
116+
# hooks:
117+
# - id: yamlfmt
118+
# - repo: https://github.com/pre-commit/pygrep-hooks
119+
# rev: "f6fb13e9516d1a9720a30a4049c930235abd642e"
120+
# hooks:
121+
# - id: python-check-blanket-noqa
122+
# - id: python-check-blanket-type-ignore
123+
# - id: python-no-log-warn
124+
# - id: python-no-eval
125+
# - id: python-use-type-annotations
126+
# - id: rst-backticks
127+
# - id: rst-directive-colons
128+
# - id: rst-inline-touching-normal
129+
# - repo: https://github.com/nbQA-dev/nbQA
130+
# rev: 952c895a21aced4601165c43f77188559a5e825c
131+
# hooks:
132+
# - id: nbqa-black
133+
# additional_dependencies: [jupytext, black] # optional, only if you're using Jupytext
134+
# - id: nbqa-pyupgrade
135+
# args: ["--py37-plus"]
136+
# - id: nbqa-flake8
137+
# - id: nbqa-isort
138+
# args: ["--float-to-top"]
139+
- repo: https://github.com/astral-sh/ruff-pre-commit
140+
rev: v0.13.1
141141
hooks:
142-
- id: ruff
142+
- id: ruff-check
143+
args: [--fix]
143144

144145
exclude: tests/generate_references.py

meshwell/labeledentity.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ def filter_tags_by_target_dimension(self, target_dimension):
130130
]
131131
case -1:
132132
warnings.warn(
133-
"Target dimension requested is 3, but entity is 2D; skipping resolution assignment."
133+
"Target dimension requested is 3, but entity is 2D; skipping resolution assignment.",
134+
stacklevel=2,
134135
)
135136
return []
136137

@@ -164,7 +165,7 @@ def filter_by_target_and_tags(target_dimension, tags, min_mass, max_mass):
164165
]
165166
return (
166167
{tag: self.model.occ.getMass(target_dimension, tag) for tag in tags}
167-
if tags is not []
168+
if tags != []
168169
else {}
169170
)
170171

meshwell/resolution.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ def apply(
141141
restrict_to_tags=None,
142142
) -> int:
143143
if self.entity_str == "RegionsList":
144-
warnings.warn("Cannot set a distance field on a Volume! Skipping")
144+
warnings.warn(
145+
"Cannot set a distance field on a Volume! Skipping", stacklevel=2
146+
)
145147
else:
146148
distance_field_index = self.apply_distance(
147149
model=model,
@@ -195,7 +197,9 @@ def apply(
195197
restrict_to_tags=None,
196198
) -> int:
197199
if self.entity_str == "RegionsList":
198-
warnings.warn("Cannot set a distance field on a Volume! Skipping")
200+
warnings.warn(
201+
"Cannot set a distance field on a Volume! Skipping", stacklevel=2
202+
)
199203
else:
200204
distance_field_index = self.apply_distance(
201205
model=model,

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ match = "(?!test).*\\.py"
132132
add-ignore = ["D100","D101","D102","D103","D104","D203","D405","D417"]
133133
convention = "google"
134134

135-
[tool.ruff]
135+
[tool.ruff.lint]
136136
select = [
137137
"E", # pycodestyle errors
138138
"W", # pycodestyle warnings
@@ -148,3 +148,5 @@ ignore = [
148148
"B905", # `zip()` without an explicit `strict=` parameter
149149
"C408", # C408 Unnecessary `dict` call (rewrite as a literal)
150150
]
151+
[tool.ruff.lint.per-file-ignores]
152+
"docs/*.py" = ["B018"] # allow useless expressions for notebooks

tests/generate_references.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import os
22
import pytest
33
from meshwell.config import PATH
4-
from contextlib import redirect_stdout
54
import argparse
65
import sys
76
import pathlib

0 commit comments

Comments
 (0)