Skip to content

Commit 13cb36b

Browse files
authored
Merge pull request #12 from pritam001/feature-lint-v2
Feature lint v2
2 parents f07ebbb + 8b46f2a commit 13cb36b

File tree

9 files changed

+57
-33
lines changed

9 files changed

+57
-33
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ dmypy.json
134134

135135
# MacOS
136136
DS_Store
137+
.DS_Store
137138

138139
# logs
139140
logs/

.pre-commit-config.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@ repos:
99
- repo: https://gitlab.com/pycqa/flake8
1010
rev: 3.8.3
1111
hooks:
12-
- id: flake8
12+
- id: flake8
13+
- repo: https://github.com/pre-commit/mirrors-isort
14+
rev: v5.3.2
15+
hooks:
16+
- id: isort

Makefile

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ FILES = input output
3535
help:
3636
@echo "$(BOLD_BLUE)-----------------------------MAKE GUIDE----------------------------$(RESET_STYLES)"
3737
@echo "$(BOLD_CYAN)make setup$(RESET_STYLES) : Setup pyflask-service"
38-
@echo "$(BOLD_CYAN)make format$(RESET_STYLES) : Format and fix python code pyflask-service"
38+
@echo "$(BOLD_CYAN)make format$(RESET_STYLES) : Format and fix python code in pyflask-service"
3939
@echo "$(BOLD_CYAN)make lint$(RESET_STYLES) : Lint pyflask-service"
4040
@echo "$(BOLD_CYAN)make test$(RESET_STYLES) : Test pyflask-service"
4141
@echo "$(BOLD_CYAN)make debug$(RESET_STYLES) : Debug pyflask-service"
@@ -46,46 +46,49 @@ help:
4646

4747

4848
setup: #: Use pip-tools, pip-compile, pip install
49-
@echo "$(BOLD_CYAN)Setting up pyflask base$(RESET_STYLES)"
49+
@echo "\n$(BOLD_CYAN)Setting up pyflask base$(RESET_STYLES)"
5050
# Check for venv, conda else exit
51-
@echo "$(BOLD_CYAN)Installing pip-tools . . .$(RESET_STYLES)"
51+
@echo "\n$(BOLD_CYAN)Installing pip-tools . . .$(RESET_STYLES)"
5252
pip install pip-tools
53-
@echo "$(BOLD_CYAN)Generating requirements$(RESET_STYLES)"
53+
@echo "\n$(BOLD_CYAN)Generating requirements$(RESET_STYLES)"
5454
pip-compile -q --build-isolation --output-file=requirements/requirements.txt requirements/requirements.in
55-
@echo "$(BOLD_CYAN)Generating dev requirements$(RESET_STYLES)"
55+
@echo "\n$(BOLD_CYAN)Generating dev requirements$(RESET_STYLES)"
5656
pip-compile -q --build-isolation --output-file=requirements/dev-requirements.txt requirements/dev-requirements.in
57-
@echo "$(BOLD_CYAN)Syncing requirements$(RESET_STYLES)"
57+
@echo "\n$(BOLD_CYAN)Syncing requirements$(RESET_STYLES)"
5858
pip-sync -q requirements/requirements.txt requirements/dev-requirements.txt
59-
@echo "$(BOLD_CYAN)Installing requirements$(RESET_STYLES)"
59+
@echo "\n$(BOLD_CYAN)Installing requirements$(RESET_STYLES)"
6060
pip install -r requirements/requirements.txt
61-
@echo "$(BOLD_CYAN)Installing dev requirements$(RESET_STYLES)"
61+
@echo "\n$(BOLD_CYAN)Installing dev requirements$(RESET_STYLES)"
6262
pip install -r requirements/dev-requirements.txt
63-
@echo "$(BOLD_CYAN)Adding pre-commit hooks$(RESET_STYLES)"
63+
@echo "\n$(BOLD_CYAN)Adding pre-commit hooks$(RESET_STYLES)"
6464
pre-commit install
6565

6666

6767
format: #: Format and fix python code with black, isort, autoflake
68-
@echo "$(BOLD_CYAN)Blackifying $(RESET_STYLES)🍳"
68+
@echo "\n$(BOLD_CYAN)Blackifying$(RESET_STYLES) 🍳"
6969
black --version
7070
black $(APP_DIR) $(TEST_DIR) $(HOME_DIR_PY_FILES)
71-
@echo "$(BOLD_CYAN)ISorting 〽️$(RESET_STYLES)"
71+
@echo "\n$(BOLD_CYAN)ISorting$(RESET_STYLES) 〽️️"
7272
isort --recursive $(APP_DIR) $(TEST_DIR) $(HOME_DIR_PY_FILES)
73-
@echo "$(BOLD_CYAN)Flaking️❄️$(RESET_STYLES)"
73+
@echo "\n$(BOLD_CYAN)Flaking$(RESET_STYLES) ❄️"
7474
flake8 --version
7575
autoflake --remove-all-unused-imports --remove-unused-variables --remove-duplicate-keys --ignore-init-module-imports -i -r $(APP_DIR) $(TEST_DIR) $(HOME_DIR_PY_FILES)
7676

7777

78-
lint: #: Run static analysis with flake8, mypy and bandit
79-
@echo "$(BOLD_CYAN)Flake linting ❄️$(RESET_STYLES)"
78+
lint: #: Run static analysis with flake8, radon, mypy and bandit
79+
@echo "\n$(BOLD_CYAN)Linting with flake8$(RESET_STYLES) ❄️"
8080
flake8 --version
8181
flake8 $(APP_DIR) $(TEST_DIR) $(HOME_DIR_PY_FILES)
82-
@echo "$(BOLD_CYAN)Static typing️️$(RESET_STYLES)⌨️"
82+
@echo "\n$(BOLD_CYAN)Checking cyclomatic complexity with radon$(RESET_STYLES) 💫️"
83+
radon --version
84+
radon cc $(APP_DIR) $(TEST_DIR) $(HOME_DIR_PY_FILES) --total-average -nc
85+
@echo "\n$(BOLD_CYAN)Static typing with mypy$(RESET_STYLES) ⌨️"
8386
mypy --version
8487
mypy $(APP_DIR) $(HOME_DIR_PY_FILES)
85-
@echo "$(BOLD_CYAN)Securing with bandit️🕵️️$(RESET_STYLES)"
88+
@echo "\n$(BOLD_CYAN)Securing with bandit$(RESET_STYLES) 🕵️️"
8689
bandit --version
8790
bandit -l -i -r . --format=custom
88-
@echo "$(BOLD_CYAN)Running pre-commit hooks 🏁️️️$(RESET_STYLES)"
91+
@echo "\n$(BOLD_CYAN)Running pre-commit hooks$(RESET_STYLES) 🏁️️️"
8992
pre-commit run --all-files
90-
@echo "$(BOLD_CYAN)All checks passed 🏳️️️️$(RESET_STYLES)"
93+
@echo "\n$(BOLD_CYAN)All checks passed$(RESET_STYLES) 🏳️️️️"
9194

README.md

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
pyflask-microservice-base
22
------------------------------------------------------------------------------
3-
An "optionally opinionated and structured" flask boilerplate microservice for ideal development
3+
An "optionally opinionated and structured" flask boilerplate microservice for jump-starting development
44

55
![Built with](https://img.shields.io/badge/-Built%20with-073551?style=flat-square)
66
![Python](https://img.shields.io/badge/-Python-3776AB?style=flat-square&logo=Python&logoColor=white)
77
![Flask](https://img.shields.io/badge/-Flask-000000?style=flat-square&logo=flask&logoColor=white)
88
![License](https://img.shields.io/github/license/pritam001/pyflask-microservice-base?style=flat-square&label=License)
9+
![WIP](https://img.shields.io/badge/%20%F0%9F%9A%A7%20-Dev%20in%20progress-important)
10+
911

1012
Tools
1113
------------------------------------------------------------------------------
12-
[![Min Python Version 3.8+](https://img.shields.io/badge/python-3.8+-3776AB.svg)](https://www.python.org/download/releases/3.8.0/)
13-
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
14-
[![Static Analysis: flake8](https://img.shields.io/badge/static%20analysis-flake8-white.svg)](https://www.python.org/dev/peps/pep-0008/)
15-
[![Static Typing: mypy](https://img.shields.io/badge/static%20typing-mypy-blue.svg)](https://www.python.org/dev/peps/pep-0008/)
16-
[![Security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)
17-
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
18-
19-
Development Status
20-
------------------------------------------------------------------------------
21-
![WIP](https://img.shields.io/badge/%20%F0%9F%9A%A7%20-Work%20in%20progress-important)
14+
[![Min Python Version 3.8+](https://img.shields.io/badge/python-3.8+-3776AB.svg?style=flat)](https://www.python.org/download/releases/3.8.0/)
15+
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat)](https://github.com/psf/black)
16+
[![Static Analysis: flake8](https://img.shields.io/badge/static%20analysis-flake8-cccccc.svg?style=flat)](https://github.com/PyCQA/flake8/)
17+
[![Cyclomatic Complexity: radon](https://img.shields.io/badge/cyclomatic%20complexity-radon-ff5252.svg?style=flat)](https://github.com/rubik/radon)
18+
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://timothycrosley.github.io/isort/)
19+
[![Static Typing: mypy](https://img.shields.io/badge/static%20typing-mypy-blue.svg?style=flat)](https://github.com/python/mypy/)
20+
[![Security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg?style=flat)](https://github.com/PyCQA/bandit)
21+
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?style=flat&logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
22+
2223

2324
Usage Guide
2425
------------------------------------------------------------------------------
@@ -37,10 +38,19 @@ Steps for creating boilerplate project in GitHub
3738
\** [Guide to Conda environment](https://github.com/pritam001/pyflask-microservice-base/blob/master/documentation/conda.md)
3839

3940

41+
Make Guide
42+
------------------------------------------------------------------------------
43+
Type `make help` for available commands
44+
45+
<p align="center"><img src="documentation/assets/make-help.gif" /></p>
46+
4047

4148
Linting Guide
4249
------------------------------------------------------------------------------
4350
`make format` : Format and fix python code with black, isort, autoflake
4451

45-
`make lint` : Run static analysis with flake8, mypy and bandit
52+
<p align="center"><img src="documentation/assets/make-format.gif" /></p>
53+
54+
`make lint` : Run static analysis with flake8, radon, mypy and bandit
4655

56+
<p align="center"><img src="documentation/assets/make-lint.gif" /></p>
1.22 MB
Loading

documentation/assets/make-help.gif

338 KB
Loading

documentation/assets/make-lint.gif

1.95 MB
Loading

requirements/dev-requirements.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ isort
1010
mypy
1111
# Security oriented static analyser for python code
1212
bandit
13+
# Complexity analysis
14+
radon
1315

1416
# Flake8
1517
flake8

requirements/dev-requirements.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ bandit==1.6.2 # via -r requirements/dev-requirements.in
1212
black==19.10b0 # via -r requirements/dev-requirements.in
1313
cfgv==3.2.0 # via pre-commit
1414
click==7.1.2 # via black
15+
colorama==0.4.3 # via radon
1516
distlib==0.3.1 # via virtualenv
1617
filelock==3.0.12 # via virtualenv
1718
flake8-blind-except==0.1.1 # via -r requirements/dev-requirements.in
@@ -21,17 +22,19 @@ flake8-comprehensions==3.2.3 # via -r requirements/dev-requirements.in
2122
flake8-flask==0.9.3 # via -r requirements/dev-requirements.in
2223
flake8-logging-format==0.6.0 # via -r requirements/dev-requirements.in
2324
flake8-plugin-utils==1.3.1 # via flake8-breakpoint, flake8-pytest-style, flake8-return
24-
flake8-polyfill==1.0.2 # via pep8-naming
25+
flake8-polyfill==1.0.2 # via pep8-naming, radon
2526
flake8-print==3.1.4 # via -r requirements/dev-requirements.in
2627
flake8-pytest-style==1.2.3 # via -r requirements/dev-requirements.in
2728
flake8-pytest==1.3 # via -r requirements/dev-requirements.in
2829
flake8-return==1.1.2 # via -r requirements/dev-requirements.in
2930
flake8==3.8.3 # via -r requirements/dev-requirements.in, flake8-builtins, flake8-comprehensions, flake8-flask, flake8-polyfill, flake8-print, flake8-pytest
31+
future==0.18.2 # via radon
3032
gitdb==4.0.5 # via gitpython
3133
gitpython==3.1.7 # via bandit
3234
identify==1.4.25 # via pre-commit
3335
isort==4.3.21 # via -r requirements/dev-requirements.in, pylint
3436
lazy-object-proxy==1.4.3 # via astroid
37+
mando==0.6.4 # via radon
3538
mccabe==0.6.1 # via flake8, pylint
3639
mypy-extensions==0.4.3 # via mypy
3740
mypy==0.782 # via -r requirements/dev-requirements.in
@@ -45,8 +48,9 @@ pyflakes==2.2.0 # via autoflake, flake8
4548
pylint==2.5.3 # via -r requirements/dev-requirements.in
4649
pyyaml==5.3.1 # via bandit, pre-commit
4750
r2c-py-ast==0.1.0b1 # via flake8-flask
51+
radon==4.2.0 # via -r requirements/dev-requirements.in
4852
regex==2020.7.14 # via black
49-
six==1.15.0 # via astroid, bandit, flake8-print, virtualenv
53+
six==1.15.0 # via astroid, bandit, flake8-print, mando, virtualenv
5054
smmap==3.0.4 # via gitdb
5155
stevedore==3.2.0 # via bandit
5256
toml==0.10.1 # via black, pre-commit, pylint

0 commit comments

Comments
 (0)