Skip to content

Commit 5e3e2c7

Browse files
author
Bastien Gautier
committed
Add flake8 config + modify install processus
1 parent c1522b9 commit 5e3e2c7

File tree

6 files changed

+125
-15
lines changed

6 files changed

+125
-15
lines changed

.devcontainer/check-post-install.sh

100644100755
Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,25 @@
22

33
RED="\e[31m"
44
GREEN="\e[32m"
5+
BLUE="\e[34m"
56
ENDCOLOR="\e[0m"
67

7-
echo -e "\n${GREEN}> Display pip info/version.${ENDCOLOR}\n"
8-
pip --version
8+
echo -e "\n${BLUE}#####################################"
9+
echo -e "${BLUE}#### CHECK-POST-INSTALL.SH ####${ENDCOLOR}"
10+
echo -e "${BLUE}#####################################"
11+
12+
source /workspaces/app/.venv/bin/activate
13+
14+
if which pip >/dev/null; then
15+
echo -e "\n${GREEN}> Display PIP info/version.${ENDCOLOR}\n"
16+
pip --version
17+
fi
18+
19+
if which poetry >/dev/null; then
20+
echo -e "\n${GREEN}> Display POETRY info/version.${ENDCOLOR}\n"
21+
poetry --version
22+
fi
923

1024
# ADD [here] your other verification todo.
1125

26+
echo -e ""

.devcontainer/install.sh

Lines changed: 95 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,118 @@
22

33
RED="\e[31m"
44
GREEN="\e[32m"
5+
BLUE="\e[34m"
6+
YELLOW="\e[33m"
57
ENDCOLOR="\e[0m"
68

7-
echo -e "\n${GREEN}> Configure environment.${ENDCOLOR}\n"
9+
echo -e "\n${BLUE}################################"
10+
echo -e "${BLUE}#### INSTALL.SH ####${ENDCOLOR}"
11+
echo -e "${BLUE}################################"
12+
13+
echo -e "\n${GREEN}> Configure virtual environment.${ENDCOLOR}\n"
814

915
sudo chgrp vscode /workspaces/app/.venv
1016
sudo chown vscode /workspaces/app/.venv
1117

1218
git config --global --add safe.directory /workspaces/app
13-
git config core.eol lf
14-
git config core.autocrlf false
19+
git config --global core.eol lf
20+
git config --global core.autocrlf false
1521

1622
python3 -m venv /workspaces/app/.venv
1723
PATH="/workspaces/app/.venv/bin:$PATH"
1824

1925
echo -e "Done.\n"
2026

21-
echo -e "${GREEN}> Update pip tool and install dependencies.${ENDCOLOR}\n"
27+
echo -e "${GREEN}> Identify the packaging and dependency manager to install.${ENDCOLOR}\n"
28+
29+
PIP_MANAGER=false
30+
POETRY_MANAGER=false
31+
32+
NEW_POETRY_INSTALL=false
33+
34+
FILE=/workspaces/app/requirements.txt
35+
36+
if [ -f "$FILE" ];
37+
then
38+
echo -e "PIP configuration file was found (requirements.txt).\n"
39+
PIP_MANAGER=true
40+
fi
41+
42+
FILE=/workspaces/app/pyproject.toml
43+
44+
if [ -f "$FILE" ];
45+
then
46+
echo -e "POETRY configuration file was found (pyproject.toml).${ENDCOLOR}"
47+
POETRY_MANAGER=true
48+
fi
49+
50+
if [ "$POETRY_MANAGER" = true ] && [ "$PIP_MANAGER" = true ];
51+
then
52+
echo -e "${RED}> ERROR: You cannot define two packaging and dependency manager in the same time.${ENDCOLOR}\n"
53+
exit 1
54+
fi
55+
56+
if [ "$POETRY_MANAGER" = false ] && [ "$PIP_MANAGER" = false ];
57+
then
58+
59+
echo -e "${YELLOW}No packaging and dependency manager was found.${ENDCOLOR}"
60+
echo -e "${YELLOW}Type 'PIP' or 'POETRY' if you want to install a packaging and dependency manager !${ENDCOLOR}"
61+
echo -e "${YELLOW}Another option will install no packaging and dependency manager.${ENDCOLOR}"
62+
echo -e "${YELLOW}Your selection :${ENDCOLOR}"
63+
64+
read MANAGER
65+
echo -e "The following packaging and dependency manager will be installed : $MANAGER\n"
66+
67+
if [ "${MANAGER^^}" = "POETRY" ]
68+
then
69+
POETRY_MANAGER=true
70+
NEW_POETRY_INSTALL=true
71+
fi
72+
73+
if [ "${MANAGER^^}" = "PIP" ]
74+
then
75+
PIP_MANAGER=true
76+
touch /workspaces/app/requirements.txt
77+
touch /workspaces/app/requirements-dev.txt
78+
fi
79+
80+
fi
2281

2382
source /workspaces/app/.venv/bin/activate
24-
pip install --upgrade pip
2583

26-
# pip install keyring artifacts-keyring
84+
if [ "$PIP_MANAGER" = true ];
85+
then
86+
87+
echo -e "${GREEN}> Update PIP tool and install dependencies.${ENDCOLOR}\n"
88+
89+
pip install --upgrade pip
90+
91+
# pip install keyring artifacts-keyring
92+
93+
# cat <<EOF >> /workspaces/app/.venv/pip.conf
94+
# [global]
95+
# extra-index-url=https://pkgs.dev.azure.com/...
96+
# EOF
97+
98+
pip install -r /workspaces/app/requirements-dev.txt
99+
pip install -r /workspaces/app/requirements.txt
100+
101+
fi
102+
103+
if [ "$POETRY_MANAGER" = true ];
104+
then
105+
106+
echo -e "${GREEN}> Install POETRY tool and install dependencies.${ENDCOLOR}\n"
107+
curl -sSL https://install.python-poetry.org | python3 -
108+
poetry completions bash >> ~/.bash_completion
109+
110+
if [ "$POETRY_MANAGER" = true ];
111+
then
112+
poetry init
113+
fi
27114

28-
# cat <<EOF >> /workspaces/app/.venv/pip.conf
29-
# [global]
30-
# extra-index-url=https://pkgs.dev.azure.com/...
31-
# EOF
115+
poetry install
32116

33-
pip install -r /workspaces/app/requirements-dev.txt
34-
pip install -r /workspaces/app/requirements.txt
117+
fi
35118

36119
/workspaces/app/.devcontainer/check-post-install.sh

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"python.linting.mypyArgs": [],
1010
"python.linting.pylintEnabled": true,
1111
"python.linting.pylintPath": "/workspaces/app/.venv/bin/pylint",
12+
"python.linting.flake8Enabled": true,
13+
"python.linting.flake8Path": "/workspaces/app/.venv/bin/flake8",
1214
"python.linting.enabled": true,
1315
"python.formatting.provider": "yapf",
1416
"python.formatting.yapfPath": "/workspaces/app/.venv/bin/yapf",
@@ -19,7 +21,8 @@
1921
"files.eol": "\n",
2022
"files.exclude": {
2123
"**/__pycache__": true,
22-
"**/.mypy_cache": true
24+
"**/.mypy_cache": true,
25+
"**/.venv": true
2326
},
2427
"python.analysis.typeCheckingMode": "strict",
2528
"python.analysis.importFormat": "absolute",

myproject/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
# Pylint: Line too long (110/100)
1414
# Pylama: Line too long (110 > 100 characters) [pycodestyle]
15+
# Flake8: Line too long (110 > 100 characters) [pycodestyle]
1516
# > Change the configuration or the code to resolve the issue.
1617

1718
import pandas as pd

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ pylama
22
pylint
33
mypy
44
yapf
5+
flake8

setup.cfg

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,10 @@ allow-global-unused-variables=no
165165
# Only show warnings with the listed confidence levels. Leave empty to show
166166
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED.
167167
confidence=
168+
169+
[flake8]
170+
171+
# extend-ignore = E203
172+
max-line-length = 100
173+
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist
174+
max-complexity = 10

0 commit comments

Comments
 (0)