Skip to content

Commit

Permalink
Centralize black & isort configuration
Browse files Browse the repository at this point in the history
Run black and isort from the root and apply it unconditionally to every
file in the repository.

Refs #1773.
  • Loading branch information
legoktm committed Feb 22, 2024
1 parent 1288bbb commit 03c0d83
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 363 deletions.
21 changes: 20 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,30 @@ lint-desktop: ## Lint .desktop files
find . -name *.desktop -type f -not -path '*/\.git/*' | xargs desktop-file-validate

.PHONY: lint
lint: bandit ## Run linters and formatters
lint: check-black check-isort bandit ## Run linters and formatters

.PHONY: fix
fix: black isort ## Fix lint and formatting issues

bandit: ## Run bandit security checks
@poetry run bandit -c pyproject.toml -r . --severity-level medium

.PHONY: black
black: ## Update Python source code formatting with black
@poetry run black .

.PHONY: check-black
check-black: ## Check Python source code formatting with black
@poetry run black --check --diff .

.PHONY: isort
isort: ## Update Python import organization with isort
@poetry run isort .

.PHONY: check-isort
check-isort: ## Check Python import organization with isort
@poetry run isort --check-only --diff .

safety: ## Run safety dependency checks on build dependencies
find . -name build-requirements.txt | xargs -n1 poetry run safety check --full-report \
--ignore 51668 \
Expand Down
26 changes: 1 addition & 25 deletions client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,6 @@ semgrep-local:
@echo "Running semgrep with local rules..."
@poetry run semgrep $(SEMGREP_FLAGS) --config ".semgrep"

.PHONY: black
black: ## Format Python source code with black
@poetry run black \
./ \
scripts/*.py

.PHONY: check-black
check-black: ## Check Python source code formatting with black
@poetry run black --check --diff \
./ \
scripts/*.py

.PHONY: isort
isort: ## Run isort to organize Python imports
@poetry run isort --skip-glob .venv \
./ \
scripts/*.py

.PHONY: check-isort
check-isort: ## Check Python import organization with isort
@poetry run isort --skip-glob .venv --check-only --diff \
./ scripts \
/*.py

.PHONY: mypy
mypy: ## Run static type checker
@poetry run mypy --ignore-missing-imports \
Expand Down Expand Up @@ -114,7 +90,7 @@ flake8: ## Run flake8 linting
@poetry run flake8 securedrop_client tests

.PHONY: lint
lint: check-black check-isort flake8 mypy semgrep ## Run all linters
lint: flake8 mypy semgrep ## Run all linters

.PHONY: check
check: clean lint test-random test-integration test-functional ## Run the full CI test suite
Expand Down
89 changes: 2 additions & 87 deletions client/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions client/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ PyQt5-sip = [
]
PyAutoGUI = "*"
babel = "^2.12.1"
black = "^23.7.0"
diffoscope = "*"
flake8 = "^6.0.0"
flaky = "*"
isort = "*"
mypy = "^1.4.1"
polib = "*"
pyqt5-stubs = "*"
Expand All @@ -50,15 +48,3 @@ types-polib = "*"
types-python-dateutil = "*"
types-requests = "^2.31.0"
types-setuptools = "^68.0.0"

[tool.black]
line-length = 100

[tool.isort]
line_length = 100
indent = ' '
multi_line_output = 3
ensure_newline_before_comments = true
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
10 changes: 1 addition & 9 deletions export/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@
all: help

.PHONY: lint
lint: check-black flake8 mypy semgrep ## Run all linters
lint: flake8 mypy semgrep ## Run all linters


.PHONY: check
check: lint test ## Run linter and tests

.PHONY: check-black
check-black: ## Check Python source code formatting with black
@poetry run black --check --diff ./

TESTS ?= tests
.PHONY: test
test: ## Run tests
Expand All @@ -26,10 +22,6 @@ flake8: ## Run flake8 linter
mypy: ## Type check Python files
poetry run mypy .

.PHONY: black
black: ## Format Python source code with black
@poetry run black ./

SEMGREP_FLAGS := --exclude "tests/" --error --strict --verbose

.PHONY: semgrep
Expand Down
72 changes: 2 additions & 70 deletions export/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion export/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ python = "^3.9"
pexpect = "^4.9.0"

[tool.poetry.group.dev.dependencies]
black = "^23.7.0"
flake8 = "^6.0.0"
mypy = "^1.4.1"
types-setuptools = "^68.0.0"
Expand Down
Loading

0 comments on commit 03c0d83

Please sign in to comment.