Skip to content

Commit

Permalink
Now use ruff format to replace black
Browse files Browse the repository at this point in the history
  • Loading branch information
xymy committed Dec 9, 2023
1 parent 4d45a30 commit 1914516
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 38 deletions.
7 changes: 2 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@ repos:
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.11.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
args: [--fix]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.1
hooks:
Expand Down
1 change: 0 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"recommendations": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.black-formatter",
"ms-python.mypy-type-checker",
"charliermarsh.ruff",
]
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"python.analysis.autoImportCompletions": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.ruff": "explicit",
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Removed `glob_scanner()` and `glob_filter()` functions.

### Documentation

- Removed `black` badge from documentation.

### Linting

- Removed `pyupgrade`.
- Removed `black`.
- Adopted `ruff format`.

### Testing

Expand Down
54 changes: 25 additions & 29 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ docs = [
"sphinx-copybutton>=0.5",
]
lint = [
# https://black.readthedocs.io/en/stable/
"black>=23.11",
# https://docs.astral.sh/ruff/
"ruff>=0.1.6",
# https://mypy.readthedocs.io/en/stable/
Expand Down Expand Up @@ -124,8 +122,8 @@ HYPOTHESIS_STORAGE_DIRECTORY = "{root}{/}.cache{/}hypothesis"
[tool.hatch.envs.default.scripts]
docs = "python {root}{/}docs{/}release.py {args}"
lint = [
"black {root}{/}src {root}{/}tests",
"ruff {root}{/}src {root}{/}tests",
"ruff check {root}{/}src {root}{/}tests",
"ruff format {root}{/}src {root}{/}tests",
"mypy {root}{/}src {root}{/}tests",
]
test = [
Expand All @@ -134,10 +132,6 @@ test = [
"python -m coverage report",
]

[tool.black]
line-length = 120
target-version = ["py39"]

[tool.ruff]
line-length = 120
target-version = "py39"
Expand All @@ -146,27 +140,29 @@ src = ["src"]
show-fixes = true
show-source = true
select = [
"F", # pyflakes
"E", # pycodestyle error
"W", # pycodestyle warning
"D3", # pydocstyle
"PLE", # pylint error
"PLW", # pylint warning
"YTT", # flake8-2020
"BLE", # flake8-blind-except
"FBT", # flake8-boolean-trap
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"ISC", # flake8-implicit-str-concat
"ICN", # flake8-import-conventions
"PIE", # flake8-pie
"PT", # flake8-pytest-style
"SIM", # flake8-simplify
"TCH", # flake8-type-checking
"FLY", # flynt
"I", # isort
"PGH", # pygrep-hooks
"UP", # pyupgrade
"F", # pyflakes
"E", # pycodestyle error
"W", # pycodestyle warning
"D3", # pydocstyle
"PLE", # pylint error
"PLW", # pylint warning
"YTT", # flake8-2020
"BLE", # flake8-blind-except
"FBT", # flake8-boolean-trap
"B", # flake8-bugbear
"COM818", # flake8-commas
"C4", # flake8-comprehensions
"ISC003", # flake8-implicit-str-concat
"ICN", # flake8-import-conventions
"PIE", # flake8-pie
"PT", # flake8-pytest-style
"RSE", # flake8-raise
"SIM", # flake8-simplify
"TCH", # flake8-type-checking
"FLY", # flynt
"I", # isort
"PGH", # pygrep-hooks
"UP", # pyupgrade
"RUF",
]
ignore = [
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ commands =
extras =
lint
commands =
black {toxinidir}{/}src {toxinidir}{/}tests
ruff --cache-dir={envdir}{/}.cache{/}ruff {toxinidir}{/}src {toxinidir}{/}tests
ruff check --cache-dir={envdir}{/}.cache{/}ruff {toxinidir}{/}src {toxinidir}{/}tests
ruff format --cache-dir={envdir}{/}.cache{/}ruff {toxinidir}{/}src {toxinidir}{/}tests
mypy --cache-dir={envdir}{/}.cache{/}mypy {toxinidir}{/}src {toxinidir}{/}tests

[testenv:docs]
Expand Down

0 comments on commit 1914516

Please sign in to comment.