File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ VENV=venv
2727ACTIVATE? =. ${VENV}/bin/activate;
2828VIRTUALENV_PYZ =etc/thirdparty/virtualenv.pyz
2929BLACK_ARGS =-l 100 .
30+ ISORT_ARGS =.
3031# Do not depend on Python to generate the SECRET_KEY
3132GET_SECRET_KEY =` base64 /dev/urandom | head -c50 `
3233# Customize with `$ make envfile ENV_FILE=/etc/vulnerablecode/.env`
@@ -61,14 +62,20 @@ envfile:
6162 @echo SECRET_KEY=\" ${GET_SECRET_KEY} \" > ${ENV_FILE}
6263
6364check :
65+ @echo " -> Run isort validation"
66+ @${ACTIVATE} isort --check-only ${ISORT_ARGS}
6467 @echo " -> Run black validation"
6568 @${ACTIVATE} black --check ${BLACK_ARGS}
6669
6770black :
6871 @echo " -> Apply black code formatter"
6972 ${VENV} /bin/black ${BLACK_ARGS}
7073
71- valid : black
74+ isort :
75+ @echo " -> Apply isort code formatter"
76+ ${VENV} /bin/isort ${ISORT_ARGS}
77+
78+ valid : isort black
7279
7380clean :
7481 @echo " -> Clean the Python env"
Original file line number Diff line number Diff line change @@ -43,4 +43,10 @@ addopts = [
4343 " -rfExXw" ,
4444 " --strict" ,
4545 " --doctest-modules"
46- ]
46+ ]
47+
48+ [tool .isort ]
49+ profile = " black"
50+ line_length = 100
51+ force_single_line = true
52+ skip_gitignore = true
Original file line number Diff line number Diff line change @@ -19,3 +19,4 @@ django-environ==0.4.5
1919defusedxml == 0.7.1
2020
2121Markdown == 3.3.4
22+ isort == 5.7.0
Original file line number Diff line number Diff line change 2020# VulnerableCode is a free software code scanning tool from nexB Inc. and others.
2121# Visit https://github.com/nexB/vulnerablecode/ for support and download.
2222
23- from os .path import dirname
24- from os .path import join
2523import subprocess
2624import sys
2725import unittest
26+ from os .path import dirname , join
2827
2928root_dir = dirname (dirname (dirname (__file__ )))
3029bin_dir = dirname (sys .executable )
@@ -36,4 +35,16 @@ def test_codestyle(self):
3635 try :
3736 subprocess .check_output (args .split (), cwd = root_dir )
3837 except Exception as e :
39- raise Exception (f"Black style check failed, please format the code using black" ) from e
38+ raise Exception (
39+ "Black style check failed, please format the code using black -l 100 . "
40+ "Alternatively, run ``make valid``"
41+ ) from e
42+
43+ args = join (bin_dir , "isort --check-only ." )
44+ try :
45+ subprocess .check_output (args .split (), cwd = root_dir )
46+ except Exception as e :
47+ raise Exception (
48+ "Unsorted imports, please sort your imports using isort. "
49+ "Alternatively, run ``make valid``"
50+ ) from e
You can’t perform that action at this time.
0 commit comments