Skip to content

Commit

Permalink
Replace yapf with ruff
Browse files Browse the repository at this point in the history
olzhasar-reef committed Dec 20, 2024
1 parent d49f490 commit a43fc8d
Showing 6 changed files with 374 additions and 322 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ In order to make it easier to contribute, core developers of this project:
* maintain a set of unit tests
* maintain a set of integration tests (run with a production cloud)
* maintain development automation tools using [nox](https://github.com/theacodes/nox) that can easily:
* format the code using [yapf](https://github.com/google/yapf) and [ruff](https://github.com/astral-sh/ruff)
* format the code using [ruff](https://github.com/astral-sh/ruff)
* run linters to find subtle/potential issues with maintainability
* run the test suite on multiple Python versions using [pytest](https://github.com/pytest-dev/pytest)
* maintain Continuous Integration (by using GitHub Actions) that:
1 change: 1 addition & 0 deletions changelog.d/+replace_yapf_with_ruff.infrastructure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove yapf in favor of ruff.
5 changes: 2 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -137,9 +137,8 @@ def get_versions() -> list[str]:
def format_(session):
"""Lint the code and apply fixes in-place whenever possible."""
pdm_install(session, 'format')
# TODO: incremental mode for yapf
session.run('yapf', '--in-place', '--parallel', '--recursive', *PY_PATHS)
session.run('ruff', 'check', '--fix', *PY_PATHS)
session.run('ruff', 'format', *PY_PATHS)
# session.run(
# 'docformatter',
# '--in-place',
@@ -154,8 +153,8 @@ def format_(session):
def lint(session):
"""Run linters in readonly mode."""
pdm_install(session, 'lint', 'doc', 'full', 'license')
session.run('yapf', '--diff', '--parallel', '--recursive', *PY_PATHS)
session.run('ruff', 'check', *PY_PATHS)
session.run('ruff', 'format', *PY_PATHS)
# session.run(
# 'docformatter',
# '--check',
670 changes: 363 additions & 307 deletions pdm.lock

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -120,6 +120,10 @@ ignore = [
"E501", # TODO: remove E501 once docstrings are formatted
]
line-length = 100
target-version = "py38"

[tool.ruff.format]
quote-style = "single"

[tool.ruff.per-file-ignores]
"__init__.py" = ["F401"]
@@ -185,12 +189,10 @@ lock_bundle = {composite=["assert_prod_python", "lock_prod_no_cross_platform"]}

[tool.pdm.dev-dependencies]
format = [
"yapf==0.27",
"ruff==0.0.272",
"ruff~=0.8.4",
]
lint = [
"yapf==0.27",
"ruff==0.0.272",
"ruff~=0.8.4",
"pytest==8.3.3",
"liccheck>=0.9.2",
"setuptools>=60", # required by liccheck
8 changes: 1 addition & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
[yapf]
based_on_style=facebook
COLUMN_LIMIT=100
SPACE_BETWEEN_ENDING_COMMA_AND_CLOSING_BRACKET=False
SPLIT_PENALTY_AFTER_OPENING_BRACKET=0

[tool:pytest]
markers =
require_secrets: mark a test as requiring secrets such as API keys

[coverage:run]
branch=true
branch=true

0 comments on commit a43fc8d

Please sign in to comment.