Skip to content

chore/replace black by ruff format #93

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

Merged
merged 2 commits into from
May 29, 2024
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
16 changes: 4 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,14 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace

# black - formatting
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
name: black
args:
- "--config"
- "./pyproject.toml"

# ruff - linting
# ruff - linting + formatting
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.5"
rev: "v0.4.6"
hooks:
- id: ruff
name: ruff
- id: ruff-format
name: ruff-format

# mypy - lint-like type checking
- repo: https://github.com/pre-commit/mirrors-mypy
Expand Down
12 changes: 2 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@

## Prerequisites

- [Python](https://www.python.org/downloads/) **>=3.12 <3.13** (_tested with 3.12.2_)
- [Python](https://www.python.org/downloads/) **>=3.12 <3.13** (_tested with 3.12.3_)
- [pre-commit](https://pre-commit.com/#install)
- [poetry](https://python-poetry.org/docs/#installation) **>=1.2.2 <1.9** (_tested with 1.8.2_)
- [poetry](https://python-poetry.org/docs/#installation) **>=1.2.2 <1.9** (_tested with 1.8.3_)
- [docker](https://docs.docker.com/get-docker/) (_optional_)

---
Expand Down Expand Up @@ -105,14 +105,6 @@ Rules are defined in the [`pyproject.toml`](pyproject.toml).

For more configuration options and details, see the [configuration docs](https://mypy.readthedocs.io/).

### black

[black](https://black.readthedocs.io/) is an uncompromising code formatter.

Rules are defined in the [`pyproject.toml`](pyproject.toml).

For more configuration options and details, see the [configuration docs](https://black.readthedocs.io/).

### bandit

[bandit](https://bandit.readthedocs.io/) is a tool designed to find common security issues in Python code.
Expand Down
123 changes: 19 additions & 104 deletions poetry.lock

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

62 changes: 46 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
description = "Python boilerplate"
authors = ["Samuel MARLHENS <[email protected]>"]
packages = [
{ include = "*", from = "src"}
{ include = "*", from = "src" }
]
license = "MIT"
readme = "README.md"
Expand All @@ -20,11 +20,10 @@ python = "^3.12"
[tool.poetry.dev-dependencies]
pytest = "8.2.1"
pytest-cov = "5.0.0"
black = "24.4.2"
mypy = "1.10.0"
bandit = "1.7.8"
docformatter = "1.7.5"
ruff = "0.4.5"
ruff = "0.4.6"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand All @@ -35,29 +34,60 @@ backend-path = ["src"]
addopts = "-vvv"
testpaths = "tests"

[tool.black]
line_length = 90
target_version = ['py310']

[tool.ruff]
exclude = [
".venv",
".git",
extend-exclude = [
"__pycache__",
"build",
"dist",
"venv",
]
ignore = []
target-version = "py312"
line-length = 90
select = [
src = ["src", "tests"]

[tool.ruff.lint]
extend-select = [
"C4",
"D200",
"D201",
"D204",
"D205",
"D206",
"D210",
"D211",
"D213",
"D300",
"D400",
"D402",
"D403",
"D404",
"D419",
"E",
"F",
"W",
"G010",
"I001",
"INP001",
"N805",
"PERF101",
"PERF102",
"PERF401",
"PERF402",
"PGH004",
"PGH005",
"PIE794",
"PIE796",
"PIE807",
"PIE810",
"RET502",
"RET503",
"RET504",
"RET505",
"RUF015",
"RUF100",
"S101",
"T20",
"W",
]
src = ["src", "tests"]

[mypy]
files = ["src"]
strict_optional = false
strict = "true"
2 changes: 1 addition & 1 deletion src/myapplication/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def hello_world():


def main():
print(hello_world())
print(hello_world()) # noqa: T201 print only used as placeholder :)


if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion tests/test_myapplication.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@


def test_hello_world():
assert hello_world() == "Hello World"
if hello_world() != "Hello World":
raise ValueError('Expected value to be "Hello World"')