Skip to content

Commit

Permalink
update ruff config to newest version (#28)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
joshuadavidthomas and pre-commit-ci[bot] authored Feb 16, 2024
1 parent 4f2218f commit 61c49ab
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Changed

- Move from deprecated `ruff` config to new in `pyproject.toml`.

## [2024.2]

Expand Down
65 changes: 65 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,71 @@ norecursedirs = ".* bin build dist *.egg examples htmlcov logs node_modules src
python_files = "tests.py test_*.py *_tests.py"
testpaths = ["tests"]

[tool.ruff]
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".github",
".hg",
".mypy_cache",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"build",
"dist",
"migrations",
"node_modules",
"venv"
]
extend-include = ["*.pyi?"]
indent-width = 4
# Same as Black.
line-length = 88
# Assume Python >3.8.
target-version = "py38"

[tool.ruff.format]
# Like Black, indent with spaces, rather than tabs.
indent-style = "space"
# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"
# Like Black, use double quotes for strings.
quote-style = "double"

[tool.ruff.lint]
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "I"]
ignore = ["E501", "E741"] # temporary
select = [
"B", # flake8-bugbear
"E", # Pycodestyle
"F", # Pyflakes
"I", # isort
"UP" # pyupgrade
]
unfixable = []

[tool.ruff.lint.isort]
force-single-line = true
known-first-party = []
required-imports = ["from __future__ import annotations"]

[tool.ruff.lint.per-file-ignores]
# Tests can use magic values, assertions, and relative imports
"tests/**/*" = ["PLR2004", "S101", "TID252"]

[tool.ruff.lint.pyupgrade]
# Preserve types, even if a file imports `from __future__ import annotations`.
keep-runtime-typing = true

[tool.rye]
dev-dependencies = [
"bumpver>=2023.1129",
Expand Down
38 changes: 21 additions & 17 deletions src/django_twc_project/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ norecursedirs = ".* bin build dist *.egg htmlcov logs node_modules static templa
python_files = "tests.py test_*.py *_tests.py"

[tool.ruff]
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
Expand All @@ -91,6 +89,7 @@ exclude = [
".git",
".github",
".hg",
".mypy_cache",
".ruff_cache",
".svn",
".tox",
Expand All @@ -101,24 +100,14 @@ exclude = [
"dist",
"migrations",
"node_modules",
"static",
"venv"
]
# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "I"]
ignore = ["E501", "E741"] # temporary
extend-include = ["*.pyi?"]
indent-width = 4
# Same as Black.
line-length = 88
select = [
"B", # flake8-bugbear
"E", # Pycodestyle
"F", # Pyflakes
"I" # isort
]
# Assume Python {{ python_version }}.
# Assume Python {{ python_version }}
target-version = "py{{ python_version | replace('.', '') }}"
unfixable = []

[tool.ruff.format]
# Like Black, indent with spaces, rather than tabs.
Expand All @@ -128,15 +117,30 @@ line-ending = "auto"
# Like Black, use double quotes for strings.
quote-style = "double"

[tool.ruff.isort]
[tool.ruff.lint]
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "I"]
ignore = ["E501", "E741"] # temporary
select = [
"B", # flake8-bugbear
"E", # Pycodestyle
"F", # Pyflakes
"I", # isort
"UP" # pyupgrade
]
unfixable = []

[tool.ruff.lint.isort]
force-single-line = true
known-first-party = ["{{ module_name }}"]
required-imports = ["from __future__ import annotations"]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# Tests can use magic values, assertions, and relative imports
"tests/**/*" = ["PLR2004", "S101", "TID252"]

[tool.ruff.pyupgrade]
[tool.ruff.lint.pyupgrade]
# Preserve types, even if a file imports `from __future__ import annotations`.
keep-runtime-typing = true
1 change: 0 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import logging


pytest_plugins = [] # type: ignore


Expand Down
1 change: 1 addition & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from pathlib import Path

import yaml

BASE_DIR = Path(__file__).parent.parent
Expand Down

0 comments on commit 61c49ab

Please sign in to comment.