Skip to content

Commit

Permalink
adds precommit
Browse files Browse the repository at this point in the history
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
  • Loading branch information
wyli committed Jan 30, 2023
1 parent 9e4ac86 commit 5da4d62
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 26 deletions.
29 changes: 5 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,11 @@ repos:
args: ['--maxkb=1024']
- id: detect-private-key

#- repo: https://github.com/asottile/pyupgrade
# rev: v2.23.2
# hooks:
# - id: pyupgrade
# args: [--py36-plus]
# name: Upgrade code

#- repo: https://github.com/asottile/yesqa
# rev: v1.2.3
# hooks:
# - id: yesqa
# name: Unused noqa

#- repo: https://github.com/PyCQA/isort
# rev: 5.9.3
# hooks:
# - id: isort
# name: Format imports

# - repo: https://github.com/psf/black
# rev: 21.7b0
# hooks:
# - id: black
# name: Format code
- repo: https://github.com/psf/black
rev: "22.12.0"
hooks:
- id: black
- id: black-jupyter

#- repo: https://github.com/executablebooks/mdformat
# rev: 0.7.8
Expand Down
25 changes: 25 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[tool.black]
line-length = 120
target-version = ['py37', 'py38', 'py39', 'py310']
include = '\.pyi?$'
exclude = '''
(
/(
# exclude a few common directories in the root of the project
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| venv
| \.pytype
| _build
| buck-out
| build
| dist
)/
# also separately exclude a file named versioneer.py
| monai/_version.py
)
'''
4 changes: 2 additions & 2 deletions runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ for file in "${files[@]}"; do
echo Applying autofixes...
jupytext "$filename" --opt custom_cell_magics="writefile" \
--pipe "autoflake --in-place --remove-unused-variables --imports numpy,monai,matplotlib,torch,ignite {}" \
--pipe "autopep8 - --ignore W291 --max-line-length 120" \
--pipe "autopep8 - --ignore W291,E203 --max-line-length 120" \
--pipe "sed 's/ = list()/ = []/'"
fi

Expand All @@ -461,7 +461,7 @@ for file in "${files[@]}"; do
jupytext "$filename" --opt custom_cell_magics="writefile" -w --to script -o - | \
sed 's/\(^\s*\)%/\1pass # %/' | \
sed 's/\(^#.*\)$/\1 # noqa: E501/' | \
flake8 - --show-source --max-line-length 120
flake8 - --show-source --extend-ignore=E203 --max-line-length 120
success=$?
if [ ${success} -ne 0 ]
then
Expand Down

0 comments on commit 5da4d62

Please sign in to comment.