forked from faif/python-patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
87 lines (73 loc) · 1.82 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# REDNAFI
# This only works with embedded venv not virtualenv
# Install venv: python3.8 -m venv venv
# Activate venv: source venv/bin/activate
# Usage (line =black line length, path = action path, ignore= exclude folders)
# ------
# make pylinter [make pylinter line=88 path=.]
# make pyupgrade
path := .
line := 88
ignore := *env
all:
@echo
.PHONY: checkvenv
checkvenv:
# raises error if environment is not active
ifeq ("$(VIRTUAL_ENV)","")
@echo "Venv is not activated!"
@echo "Activate venv first."
@echo
exit 1
endif
.PHONY: pyupgrade
pyupgrade: checkvenv
# checks if pip-tools is installed
ifeq ("$(wildcard venv/bin/pip-compile)","")
@echo "Installing Pip-tools..."
@pip install pip-tools
endif
ifeq ("$(wildcard venv/bin/pip-sync)","")
@echo "Installing Pip-tools..."
@pip install pip-tools
endif
# pip-tools
# @pip-compile --upgrade requirements-dev.txt
@pip-sync requirements-dev.txt
.PHONY: pylinter
pylinter: checkvenv
# checks if black is installed
ifeq ("$(wildcard venv/bin/black)","")
@echo "Installing Black..."
@pip install black
endif
# checks if isort is installed
ifeq ("$(wildcard venv/bin/isort)","")
@echo "Installing Isort..."
@pip install isort
endif
# checks if flake8 is installed
ifeq ("$(wildcard venv/bin/flake8)","")
@echo -e "Installing flake8..."
@pip install flake8
@echo
endif
# black
@echo "Applying Black"
@echo "----------------\n"
@black --line-length $(line) --exclude $(ignore) $(path)
@echo
# isort
@echo "Applying Isort"
@echo "----------------\n"
@isort --atomic --profile black $(path)
@echo
# flake8
@echo "Applying Flake8"
@echo "----------------\n"
@flake8 --max-line-length "$(line)" \
--max-complexity "18" \
--select "B,C,E,F,W,T4,B9" \
--ignore "E203,E266,E501,W503,F403,F401,E402" \
--exclude ".git,__pycache__,old, build, \
dist, venv, .tox" $(path)