Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace black for ruff format #60

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ This project has been set up to quickly and easily set up a new Python package p
* [Thrusted publishers][thrusted] for PyPI releases
* [Dev Containers][devcontainer] for easy development in VS Code
* [Renovate Bot][renovate] for dependency updates
* [Black][black] for code formatting
* [mypy][mypy] for static type checking
* [pytest][pytest] for testing with code coverage
* [Ruff][ruff] for linting
* [Ruff][ruff] for linting and code formatting
* And much more!

## Create a new project
Expand Down Expand Up @@ -106,7 +105,6 @@ The [pyproject.toml](./template/pyproject.toml.j2) file of the template has a ji
Distributed under the **MIT** License. See [`LICENSE`](LICENSE) for more information.

<!-- Links -->
[black]: https://black.readthedocs.io/en/stable/
[copier]: https://copier.readthedocs.io/en/stable/
[gh-actions]: https://github.com/features/actions
[mypy]: https://mypy.readthedocs.io/en/stable/
Expand All @@ -117,6 +115,8 @@ Distributed under the **MIT** License. See [`LICENSE`](LICENSE) for more informa
[renovate]: https://docs.renovatebot.com/
[devcontainer]: https://code.visualstudio.com/docs/remote/containers

[poetry-install]: https://python-poetry.org/docs/#installation

<!-- Shields -->
[license-shield]: https://img.shields.io/github/license/klaasnicolaas/pypackage-template.svg
[releases-shield]: https://img.shields.io/github/release/klaasnicolaas/pypackage-template.svg
Expand Down
6 changes: 4 additions & 2 deletions template/.github/workflows/linting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ jobs:
poetry config virtualenvs.in-project true
- name: 🏗 Install Python dependencies
run: poetry install --no-interaction
- name: 🚀 Run Ruff
run: poetry run ruff .
- name: 🚀 Run ruff linter
run: poetry run ruff check --output-format=github .
- name: 🚀 Run ruff formatter
run: poetry run ruff format --check .

black:
name: black
Expand Down
15 changes: 8 additions & 7 deletions template/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
repos:
- repo: local
hooks:
- id: ruff
name: 🐶 Ruff
- id: ruff-check
name: 🐶 Ruff Linter
language: system
types: [python]
entry: poetry run ruff --fix
entry: poetry run ruff check --fix
require_serial: true
stages: [commit, push, manual]
- id: black
name: ☕️ Format using black
- id: ruff-format
name: 🐶 Ruff Formatter
language: system
types: [python]
entry: poetry run black
entry: poetry run ruff format
require_serial: true
stages: [commit, push, manual]
- id: blacken-docs
name: ☕️ Format documentation examples using black
language: system
Expand Down Expand Up @@ -63,7 +64,7 @@ repos:
entry: poetry run check-toml
- id: check-xml
name: ✅ Check XML files
entry: check-xml
entry: poetry run check-xml
language: system
types: [xml]
- id: check-yaml
Expand Down
15 changes: 13 additions & 2 deletions template/pyproject.toml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ Changelog = "https://github.com/{{ github_username }}/python-{{ project_slug }}/

[tool.poetry.group.dev.dependencies]
aresponses = "2.1.6"
black = "23.10.0"
blacken-docs = "1.16.0"
codespell = "2.2.6"
covdefaults = "2.3.0"
Expand All @@ -113,7 +112,7 @@ pylint = "3.0.2"
pytest = "7.4.2"
pytest-asyncio = "0.21.1"
pytest-cov = "4.1.0"
ruff = "0.1.1"
ruff = "0.1.3"
yamllint = "1.32.0"

[tool.coverage.run]
Expand Down Expand Up @@ -202,6 +201,18 @@ ignore = [
"D213", # Conflicts with other rules
"D417", # False positives in some occasions
"PLR2004", # Just annoying, not really useful

# Formatter conflicts
"COM812",
"COM819",
"D206",
"E501",
"ISC001",
"Q000",
"Q001",
"Q002",
"Q003",
"W191",
]

[tool.ruff.flake8-pytest-style]
Expand Down