🔧(backend) fix Pylint configurations
Removing the __init__.py makes it impossible for Pylint to get the sources to lint from the root folder. We manually set all the paths pylint will lint. That's not a big deal, as we'll remove Pylint any soon to rely only on ruff. I took inspiration from marsha or magnify project. I removed the now useless bash script to run Pylint command. It saves us wrapper! Plus, having a lint command running with different option locally and in the CI was quite a pain. Locally linter was running on diff files; Fixed! CI and make command has now the same behavior.
This commit is contained in:
committed by
aleb_the_flash
parent
4a011024dd
commit
d406f31bd8
2
.github/workflows/meet.yml
vendored
2
.github/workflows/meet.yml
vendored
@@ -89,7 +89,7 @@ jobs:
|
|||||||
- name: Lint code with ruff
|
- name: Lint code with ruff
|
||||||
run: ~/.local/bin/ruff check .
|
run: ~/.local/bin/ruff check .
|
||||||
- name: Lint code with pylint
|
- name: Lint code with pylint
|
||||||
run: ~/.local/bin/pylint .
|
run: ~/.local/bin/pylint meet demo core
|
||||||
|
|
||||||
test-back:
|
test-back:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -141,7 +141,7 @@ lint-ruff-check: ## lint back-end python sources with ruff
|
|||||||
|
|
||||||
lint-pylint: ## lint back-end python sources with pylint only on changed files from main
|
lint-pylint: ## lint back-end python sources with pylint only on changed files from main
|
||||||
@echo 'lint:pylint started…'
|
@echo 'lint:pylint started…'
|
||||||
bin/pylint --diff-only=origin/main
|
@$(COMPOSE_RUN_APP) pylint meet demo core
|
||||||
.PHONY: lint-pylint
|
.PHONY: lint-pylint
|
||||||
|
|
||||||
test: ## run project tests
|
test: ## run project tests
|
||||||
|
|||||||
38
bin/pylint
38
bin/pylint
@@ -1,38 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# shellcheck source=bin/_config.sh
|
|
||||||
source "$(dirname "${BASH_SOURCE[0]}")/_config.sh"
|
|
||||||
|
|
||||||
declare diff_from
|
|
||||||
declare -a paths
|
|
||||||
declare -a args
|
|
||||||
|
|
||||||
# Parse options
|
|
||||||
for arg in "$@"
|
|
||||||
do
|
|
||||||
case $arg in
|
|
||||||
--diff-only=*)
|
|
||||||
diff_from="${arg#*=}"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-*)
|
|
||||||
args+=("$arg")
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
paths+=("$arg")
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ -n "${diff_from}" ]]; then
|
|
||||||
# Run pylint only on modified files located in src/backend
|
|
||||||
# (excluding deleted files and migration files)
|
|
||||||
# shellcheck disable=SC2207
|
|
||||||
paths=($(git diff "${diff_from}" --name-only --diff-filter=d -- src/backend ':!**/migrations/*.py' | grep -E '^src/backend/.*\.py$'))
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Fix docker vs local path when project sources are mounted as a volume
|
|
||||||
read -ra paths <<< "$(echo "${paths[@]}" | sed "s|src/backend/||g")"
|
|
||||||
_dc_run app-dev pylint "${paths[@]}" "${args[@]}"
|
|
||||||
Reference in New Issue
Block a user