Skip to content

Commit

Permalink
feat: migrate from Black to Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
pmareke committed Sep 25, 2024
1 parent 9fda090 commit d64bc40
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 89 deletions.
31 changes: 16 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ local-setup: ## Sets up the local environment (e.g. install git hooks)

.PHONY: build
build: ## Install the app packages
docker build -t fastapi-boilerplate .
docker build -t fastapi-boilerplate .

.PHONY: install
install: ## Install the app packages
poetry install
rm -rf poetry.lock
poetry install

.PHONY: update
update: ## Updates the app packages
poetry update
poetry update

.PHONY: add-package
add-package: ## Installs a new package in the app. ex: make install package=XXX
poetry add $(package)
poetry install
poetry add $(package)
poetry install

.PHONY: run
run: ## Runs the app in production mode
Expand All @@ -37,40 +38,40 @@ dev: ## Runs the app in development mode

.PHONY: check-typing
check-typing: ## Run a static analyzer over the code to find issues
poetry run mypy .
poetry run mypy .

.PHONY: check-format
check-format: ## Checks the code format
poetry run black --check src tests
poetry run ruff check

.PHONY: format
format: ## Format python code
poetry run black src tests
poetry run ruff format

.PHONY: test-unit
test-unit: ## Run unit tests
PYTHONPATH=. poetry run pytest -n auto tests/unit -ra
PYTHONPATH=. poetry run pytest -n auto tests/unit -ra

.PHONY: test-integration
test-integration: ## Run integration tests
PYTHONPATH=. poetry run pytest -n auto tests/integration -ra
PYTHONPATH=. poetry run pytest -n auto tests/integration -ra

.PHONY: test-acceptance
test-acceptance: ## Run acceptance tests
PYTHONPATH=. poetry run pytest -n auto tests/acceptance -ra
PYTHONPATH=. poetry run pytest -n auto tests/acceptance -ra

.PHONY: test
test: test-unit test-integration test-acceptance ## Run all the tests

.PHONY: watch
watch: ## Run all the tests in watch mode
PYTHONPATH=. poetry run ptw --runner "pytest -n auto tests -ra"
PYTHONPATH=. poetry run ptw --runner "pytest -n auto tests -ra"

.PHONY: coverage
coverage: ## Generates the coverage report
PYTHONPATH=. poetry run coverage run --branch -m pytest tests
PYTHONPATH=. poetry run coverage html
@open "${PWD}/htmlcov/index.html"
PYTHONPATH=. poetry run coverage run --branch -m pytest tests
PYTHONPATH=. poetry run coverage html
@open "${PWD}/htmlcov/index.html"

.PHONY: pre-commit
pre-commit: check-format check-typing test-unit
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ This project uses [Poetry](https://python-poetry.org) as the package manager.
### Code style

- [mypy](https://mypy.readthedocs.io/en/stable/): A static type checker.
- [black](https://black.readthedocs.io/en/stable/): A Python formatter.
- [ruff](https://docs.astral.sh/ruff/installation/): A Python linter and formatter.

100 changes: 28 additions & 72 deletions poetry.lock

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

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ pytest-watch = "^4.2.0"
expects = "^0.9.0"
doublex = "^1.9.6.1"
coverage = "^7.6.1"
black = "^24.8.0"
mypy = "^1.11.2"
ruff = "^0.6.7"

[build-system]
requires = ["poetry-core"]
Expand Down

0 comments on commit d64bc40

Please sign in to comment.