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
37 changes: 36 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ ifndef PY
PY = 3
endif

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

LOCAL_PYTHON_BIN = './envhelp/lpython'

ifdef PYTHON_BIN
Expand Down Expand Up @@ -35,7 +40,37 @@ ifneq ($(MIG_ENV),'local')
@echo "unavailable outside local development environment"
@exit 1
endif
$(LOCAL_PYTHON_BIN) -m autopep8 --ignore E402 -i
@make format-python

.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)

.PHONY: lint
lint:
ifneq ($(MIG_ENV),'local')
@echo "unavailable outside local development environment"
@exit 1
endif
@make lint-python

.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)

.PHONY: clean
clean:
Expand Down
2 changes: 2 additions & 0 deletions local-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# This list is mainly used to specify addons needed for the unit tests.
# We only need autopep8 on py 3 as it's used in 'make fmt' (with py3)
autopep8;python_version >= "3"
black
isort
# We need paramiko for the ssh unit tests
# NOTE: paramiko-3.0.0 dropped python2 and python3.6 support
paramiko;python_version >= "3.7"
Expand Down
Loading