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

fix: switch to ruff-format #696

Merged
merged 4 commits into from
Oct 30, 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
10 changes: 3 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,25 @@ repos:
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
- id: double-quote-string-fixer
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.15
hooks:
- id: validate-pyproject
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.10.1
hooks:
- id: black
- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black==23.7.0]
additional_dependencies: [black==23.*]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.3"
hooks:
- id: prettier
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.2
rev: v0.1.3
hooks:
- id: ruff
args: [--fix, --show-fixes]
- id: ruff-format
- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
hooks:
Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,13 @@ module = [
]
ignore_missing_imports = true

[tool.black]
line-length = 127
skip-string-normalization = true

[tool.ruff]
src = ["src"]
line-length = 127

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

[tool.ruff.lint]
exclude = ["tests/packages/test-bad-syntax"]
extend-select = [
Expand Down
4 changes: 2 additions & 2 deletions src/build/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def main_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
description=textwrap.indent(
textwrap.dedent(
'''
"""
A simple, correct Python build frontend.

By default, a source distribution (sdist) is built from {srcdir}
Expand All @@ -275,7 +275,7 @@ def main_parser() -> argparse.ArgumentParser:
If you do this, the default behavior will be disabled, and all
artifacts will be built from {srcdir} (even if you combine
-w/--wheel with -s/--sdist, the wheel will be built from {srcdir}).
'''
"""
).strip(),
' ',
),
Expand Down
7 changes: 5 additions & 2 deletions src/build/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ def __init__(
self,
exception: Exception,
description: str | None = None,
exc_info: tuple[type[BaseException], BaseException, types.TracebackType]
| tuple[None, None, None] = (None, None, None),
exc_info: tuple[type[BaseException], BaseException, types.TracebackType] | tuple[None, None, None] = (
None,
None,
None,
),
) -> None:
super().__init__()
self.exception = exception
Expand Down
4 changes: 2 additions & 2 deletions tests/packages/test-metadata/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None):
distinfo.mkdir(parents=True, exist_ok=True)
distinfo.joinpath('METADATA').write_text(
textwrap.dedent(
f'''
f"""
Metadata-Version: 2.2
Name: {metadata['project']['name']}
Version: {metadata['project']['version']}
Summary: {metadata['project']['description']}
'''
"""
).strip()
)
return distinfo.name
Expand Down
4 changes: 2 additions & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,14 +431,14 @@ def test_venv_fail(monkeypatch, package_test_flit, tmp_dir, capsys):

assert (
stdout
== '''\
== """\
* Creating venv isolated environment...
ERROR Failed to create venv. Maybe try installing virtualenv.
Command 'test args' failed with return code 1
stdout:
stdoutput
stderr:
stderror
'''
"""
)
assert stderr == ''
8 changes: 4 additions & 4 deletions tests/test_projectbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def test_build_with_dep_on_console_script(tmp_path, demo_pkg_inline, capfd, mock
# to validate backend invocations contain the correct path we use an inline backend that will fail, but first
# provides the PATH information (and validates shutil.which is able to discover the executable - as PEP states)
toml = textwrap.dedent(
'''
"""
[build-system]
requires = ["demo_pkg_inline"]
build-backend = "build"
Expand All @@ -392,17 +392,17 @@ def test_build_with_dep_on_console_script(tmp_path, demo_pkg_inline, capfd, mock
[project]
description = "Factory ⸻ A code generator 🏭"
authors = [{name = "Łukasz Langa"}]
'''
"""
)
code = textwrap.dedent(
'''
"""
import os
import shutil
import sys
print("BB " + os.environ["PATH"])
exe_at = shutil.which("demo-pkg-inline")
print("BB " + exe_at)
'''
"""
)
(tmp_path / 'pyproject.toml').write_text(toml, encoding='UTF-8')
(tmp_path / 'build.py').write_text(code, encoding='utf-8')
Expand Down