Skip to content

Commit e7f0be5

Browse files
authored
Merge branch 'dev' into weekly_preview2
2 parents 666a9a0 + 9ea04d4 commit e7f0be5

3 files changed

Lines changed: 53 additions & 35 deletions

File tree

.pre-commit-config.yaml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ repos:
1313
hooks:
1414
- id: end-of-file-fixer
1515
- id: trailing-whitespace
16+
- id: check-ast
1617
- id: check-yaml
1718
- id: check-docstring-first
1819
- id: check-executables-have-shebangs
1920
- id: check-toml
2021
- id: check-case-conflict
22+
- id: check-illegal-windows-names
2123
- id: check-added-large-files
2224
args: ['--maxkb=1024']
2325
- id: detect-private-key
@@ -26,8 +28,9 @@ repos:
2628
args: ['--autofix', '--no-sort-keys', '--indent=4']
2729
- id: end-of-file-fixer
2830
- id: mixed-line-ending
31+
2932
- repo: https://github.com/astral-sh/ruff-pre-commit
30-
rev: v0.15.20
33+
rev: v0.16.5
3134
hooks:
3235
- id: ruff-check
3336
args: ["--fix"]
@@ -37,8 +40,25 @@ repos:
3740
^monai/_version.py
3841
)
3942
40-
- repo: https://github.com/hadialqattan/pycln
41-
rev: v2.6.0
43+
- repo: https://github.com/psf/black-pre-commit-mirror
44+
rev: 26.5.1 # Black version, keep synced with MONAI requirements
4245
hooks:
43-
- id: pycln
44-
args: [--config=pyproject.toml]
46+
- id: black
47+
language_version: python3
48+
# black will be given individual file names and so will ignore the excludes in pyproject.toml
49+
exclude: |
50+
(?x)(
51+
^versioneer.py|
52+
^monai/_version.py
53+
)
54+
55+
- repo: https://github.com/pycqa/isort
56+
rev: 9.0.1 # isort version, keep synced with MONAI requirements
57+
hooks:
58+
- id: isort
59+
name: isort (python)
60+
exclude: |
61+
(?x)(
62+
^versioneer.py|
63+
^monai/_version.py
64+
)

pyproject.toml

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ mlflow = ["mlflow>=3.15.2"]
131131
nibabel = ["nibabel"]
132132
nni = [
133133
"nni; platform_system == 'Linux' and 'arm' not in platform_machine and 'aarch' not in platform_machine",
134-
"filelock<3.12.0" # https://github.com/microsoft/nni/issues/5523
134+
"filelock<3.12.0", # https://github.com/microsoft/nni/issues/5523
135+
"typeguard<3" # https://github.com/microsoft/nni/issues/5457
135136
]
136137
onnx = ["onnx>=1.13.0", "onnxruntime; python_version <= '3.10'", "onnx_graphsurgeon", "onnxscript"]
137138
openslide = ["openslide-python", "openslide-bin"]
@@ -161,9 +162,9 @@ transformers = ["transformers>=5.5.0"] # 5.x needs the transchex BertLayer/Bert
161162
zarr = ["zarr"]
162163
# these dependencies are for testing/building only, they aren't needed for regular use so don't appear in "all"
163164
testing = [
164-
"black>=26.3.1",
165+
"black>=26.5.1",
165166
"coverage>=5.5",
166-
"isort>=5.1,<6,!=6.0.0",
167+
"isort>9.0.0",
167168
"mccabe",
168169
"packaging",
169170
"parameterized",
@@ -172,9 +173,8 @@ testing = [
172173
"pycodestyle",
173174
"pyflakes",
174175
"pyrefly>=1.0.0",
175-
"ruff>=0.14.11,<0.15",
176+
"ruff>=0.16.5",
176177
"tomli", # used in print_dependencies.py for Python<3.11
177-
"typeguard<3", # https://github.com/microsoft/nni/issues/5457
178178
"types-PyYAML",
179179
"types-setuptools"
180180
]
@@ -291,39 +291,35 @@ exclude = '''
291291
)
292292
'''
293293

294-
[tool.pycln]
295-
all = true
296-
exclude = "monai/bundle/__main__.py"
297-
298294
[tool.ruff]
299295
line-length = 120
300296
target-version = "py310"
301297

302298
[tool.ruff.lint]
303299
select = [
304-
"B", # flake8-bugbear - https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
305-
"C90", # mccabe (complexity) - https://docs.astral.sh/ruff/rules/#mccabe-c90
306-
"E", # pycodestyle errors - https://docs.astral.sh/ruff/rules/#error-e
307-
"F", # pyflakes - https://docs.astral.sh/ruff/rules/#pyflakes-f
308-
"N", # pep8-naming - https://docs.astral.sh/ruff/rules/#pep8-naming-n
309-
"PIE", # flake8-pie - https://docs.astral.sh/ruff/rules/#flake8-pie-pie
310-
"TID", # flake8-tidy-imports - https://docs.astral.sh/ruff/rules/#flake8-tidy-imports-tid
311-
"W", # pycodestyle warnings - https://docs.astral.sh/ruff/rules/#warning-w
312-
"NPY", # NumPy specific rules
313-
"UP", # pyupgrade
314-
"RUF100", # aka yesqa
300+
"B", # flake8-bugbear - https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
301+
"C90", # mccabe (complexity) - https://docs.astral.sh/ruff/rules/#mccabe-c90
302+
"E", # pycodestyle errors - https://docs.astral.sh/ruff/rules/#error-e
303+
"F", # pyflakes - https://docs.astral.sh/ruff/rules/#pyflakes-f
304+
"N", # pep8-naming - https://docs.astral.sh/ruff/rules/#pep8-naming-n
305+
"PIE", # flake8-pie - https://docs.astral.sh/ruff/rules/#flake8-pie-pie
306+
"TID", # flake8-tidy-imports - https://docs.astral.sh/ruff/rules/#flake8-tidy-imports-tid
307+
"W", # pycodestyle warnings - https://docs.astral.sh/ruff/rules/#warning-w
308+
"NPY", # NumPy specific rules - https://docs.astral.sh/ruff/rules/#numpy-specific-rules-npy
309+
"UP", # pyupgrade - https://docs.astral.sh/ruff/rules/#pyupgrade-up
310+
"RUF100", # aka yesqa - https://docs.astral.sh/ruff/rules/unused-noqa/
311+
"F401", # unused imports - https://docs.astral.sh/ruff/rules/unused-import/
315312
]
316313
extend-ignore = [
317-
"E741", # ambiguous variable name
318-
"F401", # unused import
314+
"E741", # ambiguous variable name
319315
"NPY002", # numpy-legacy-random
320-
"E203", # whitespace before ':' (pycodestyle)
321-
"E501", # line too long (pycodestyle)
322-
"C408", # unnecessary collection call (flake8-comprehensions)
323-
"N812", # lowercase imported as non lowercase (pep8-naming)
324-
"B023", # function uses loop variable (flake8-bugbear)
325-
"B905", # zip() without an explicit strict= parameter (flake8-bugbear)
326-
"B028", # no explicit stacklevel keyword argument found (flake8-bugbear)
316+
"E203", # whitespace before ':' (pycodestyle)
317+
"E501", # line too long (pycodestyle)
318+
"C408", # unnecessary collection call (flake8-comprehensions)
319+
"N812", # lowercase imported as non lowercase (pep8-naming)
320+
"B023", # function uses loop variable (flake8-bugbear)
321+
"B905", # zip() without an explicit strict= parameter (flake8-bugbear)
322+
"B028", # no explicit stacklevel keyword argument found (flake8-bugbear)
327323
]
328324

329325
[tool.ruff.lint.per-file-ignores]
@@ -336,6 +332,8 @@ extend-ignore = [
336332
"monai/apps/detection/utils/ATSS_matcher.py" = [
337333
"N999"
338334
]
335+
"__init__.py" = ["F401"] # TODO: change importation in __init__.py files to suit F401
336+
"monai/bundle/__main__.py" = ["F401"]
339337

340338
[tool.ruff.lint.mccabe]
341339
max-complexity = 50 # todo lower this treshold when yesqa id replaced with Ruff's RUF100

runtests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ function print_style_fail_msg() {
221221
echo "${red}Check failed!${noColor}"
222222
if [ "$homedir" = "$currentdir" ]
223223
then
224-
echo "Please run auto style fixes: ${green}./runtests.sh --autofix${noColor}"
224+
echo "Please run auto style fixes if necessary: ${green}./runtests.sh --autofix${noColor}"
225225
else :
226226
fi
227227
}

0 commit comments

Comments
 (0)