Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 10 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ ifndef PY
PY = 3
endif

FORMAT_ENFORCE_DIRS = state/
FORMAT_EXCLUDE_REGEX = '.*'
FORMAT_EXCLUDE_GLOB = '*'
FORMAT_LINE_LENGTH = 80

# TODO: enable on these dirs when ready, but just leave to dummy init for now
#LINT_ENFORCE_DIRS = ./bin ./mig/lib ./sbin ./tests
LINT_ENFORCE_DIRS = ./mig/__init__.py
LOCAL_PYTHON_BIN = './envhelp/lpython'

ifdef PYTHON_BIN
Expand Down Expand Up @@ -42,15 +40,11 @@ ifneq ($(MIG_ENV),'local')
endif
@make format-python

.PHONY:format-python
# NOTE: black and isort use pyproject.toml to temporarily exclude a few paths
.PHONY: format-python
format-python:
@$(LOCAL_PYTHON_BIN) -m black $(FORMAT_ENFORCE_DIRS) \
--line-length=$(FORMAT_LINE_LENGTH) \
--exclude=$(FORMAT_EXCLUDE_REGEX)
@$(LOCAL_PYTHON_BIN) -m isort $(FORMAT_ENFORCE_DIRS) \
--profile=black \
--line-length=$(FORMAT_LINE_LENGTH) \
--skip-glob=$(FORMAT_EXCLUDE_GLOB)
@$(LOCAL_PYTHON_BIN) -m black $(LINT_ENFORCE_DIRS)
@$(LOCAL_PYTHON_BIN) -m isort $(LINT_ENFORCE_DIRS)

.PHONY: lint
lint:
Expand All @@ -60,17 +54,11 @@ ifneq ($(MIG_ENV),'local')
endif
@make lint-python

# NOTE: black and isort use pyproject.toml to temporarily exclude a few paths
.PHONY: lint-python
lint-python:
@$(LOCAL_PYTHON_BIN) -m black $(FORMAT_ENFORCE_DIRS) \
--check \
--line-length=$(FORMAT_LINE_LENGTH) \
--exclude $(FORMAT_EXCLUDE_REGEX)
@$(LOCAL_PYTHON_BIN) -m isort $(FORMAT_ENFORCE_DIRS) \
--check-only \
--profile=black \
--line-length=$(FORMAT_LINE_LENGTH) \
--skip-glob=$(FORMAT_EXCLUDE_GLOB)
@$(LOCAL_PYTHON_BIN) -m black $(LINT_ENFORCE_DIRS) --check
@$(LOCAL_PYTHON_BIN) -m isort $(LINT_ENFORCE_DIRS) --check-only

.PHONY: clean
clean:
Expand Down
36 changes: 36 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Project wide settings including tooling.

# Linting tools
# TODO: fix CodeQL errors in symlinked files and disable extend-exclude+skip

[tool.black]
line-length = 80
exclude = '''
tests/data/
| tests/fixture/
'''
# NOTE: the following regex matches must be kept in sync with isort skip
extend-exclude = '''
bin/checkconf.py
| bin/createresource.py
| bin/notifypassword.py
| sbin/grid_ftps.py
| sbin/grid_openid.py
| sbin/grid_sftp.py
| sbin/grid_webdavs.py
'''

[tool.isort]
profile = "black"
line_length = 80
skip_glob = [".git/*", "tests/data/*", "tests/fixture/*"]
# NOTE: the following paths must be kept in sync with black extend-exclude
skip = [
"bin/checkconf.py",
"bin/createresource.py",
"bin/notifypassword.py",
"sbin/grid_ftps.py",
"sbin/grid_openid.py",
"sbin/grid_sftp.py",
"sbin/grid_webdavs.py"
]
Loading