Skip to content

Commit

Permalink
Add a "valid" Make command to run isort, black, and mypy
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <tdruez@nexb.com>
  • Loading branch information
tdruez committed Dec 8, 2023
1 parent a1d782b commit 1581b15
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ pip-selfcheck.json
pyvenv.cfg
.Python
/.tox/
/.pytest_cache/
/.*_cache/
venv
22 changes: 20 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
PYTHON_EXE?=python3
ACTIVATE?=. bin/activate;
VIRTUALENV_PYZ=thirdparty/virtualenv.pyz
BLACK_ARGS=--exclude=".cache|migrations|data|lib|bin|var"
BLACK_ARGS=--exclude=".cache|lib|bin|var" --line-length 100

virtualenv:
@echo "-> Bootstrap the virtualenv with PYTHON_EXE=${PYTHON_EXE}"
Expand All @@ -46,9 +46,27 @@ clean:
find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ \
-delete -type d -name '*.egg-info' -delete

isort:
@echo "-> Apply isort changes to ensure proper imports ordering"
@${ACTIVATE} isort --profile black src/ tests/

black:
@echo "-> Apply black code formatter"
@${ACTIVATE} black ${BLACK_ARGS} .

mypy:
@echo "-> Type check the Python code."
@${ACTIVATE} mypy

valid:
@${ACTIVATE} pip install -e .[lint]
@$(MAKE) isort
@$(MAKE) black
@$(MAKE) mypy

test:
@echo "-> Run the test suite"
${MANAGE} test --noinput
bin/py.test tests

.PHONY: virtualenv conf dev clean test
.PHONY: virtualenv conf dev clean isort black mypy valid test
4 changes: 1 addition & 3 deletions tests/contrib/test_purl2url.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,7 @@ def test_purl2url_get_inferred_urls():
"https://gitlab.com/tg1999/firebase",
"https://gitlab.com/tg1999/firebase/-/archive/1a122122/firebase-1a122122.tar.gz",
],
"pkg:pypi/sortedcontainers@2.4.0": [
"https://pypi.org/project/sortedcontainers/2.4.0/"
],
"pkg:pypi/sortedcontainers@2.4.0": ["https://pypi.org/project/sortedcontainers/2.4.0/"],
"pkg:rubygems/package-name": ["https://rubygems.org/gems/package-name"],
"pkg:bitbucket/birkenfeld": [],
}
Expand Down

0 comments on commit 1581b15

Please sign in to comment.