Skip to content

Commit a0b7dd3

Browse files
authored
Merge pull request #2042 from sydduckworth/replace-black-with-ruff
Replace `black` and `blacken-docs` with `ruff`
2 parents 0875af5 + 82500d6 commit a0b7dd3

8 files changed

Lines changed: 22 additions & 24 deletions

File tree

.pre-commit-config.yaml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,11 @@ repos:
4343
exclude: "asdf/(extern||_jsonschema)/.*"
4444

4545
- repo: https://github.com/astral-sh/ruff-pre-commit
46-
rev: 'v0.13.0'
46+
rev: 'v0.15.12'
4747
hooks:
48-
- id: ruff
48+
- id: ruff-check
4949
args: ["--fix"]
50-
51-
- repo: https://github.com/psf/black
52-
rev: 25.1.0
53-
hooks:
54-
- id: black
55-
56-
- repo: https://github.com/asottile/blacken-docs
57-
rev: '1.20.0'
58-
hooks:
59-
- id: blacken-docs
50+
- id: ruff-format
6051

6152
- repo: https://github.com/tombi-toml/tombi-pre-commit
6253
rev: v0.9.25

asdf/_display.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def render_table(
4040
inner_width = key_width + val_width + 1
4141

4242
# Format each row with key left-aligned and value centered
43-
content = [f"┃ {key:<{key_width-2}}{value:^{val_width-2}} ┃" for key, value in rows]
43+
content = [f"┃ {key:<{key_width - 2}}{value:^{val_width - 2}} ┃" for key, value in rows]
4444
return [
4545
"┏" + "━" * inner_width + "┓",
4646
f"┃{title:^{inner_width}s}┃", # Centered table title

asdf/_tests/test_info.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -786,9 +786,7 @@ def test_info_with_custom_extension(capsys):
786786
properties:
787787
bar:
788788
title: bar_title
789-
""".encode(
790-
"ascii"
791-
)
789+
""".encode("ascii")
792790

793791
class MyExtension:
794792
extension_uri = "asdf://somewhere.org/extensions/foo-1.0.0"

asdf/_tests/test_reference.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ def test_make_reference(tmp_path):
174174

175175
ff.write_to(os.path.join(str(tmp_path), "source.asdf"))
176176

177-
with (asdf.open(os.path.join(str(tmp_path), "source.asdf")) as ff,):
177+
with (
178+
asdf.open(os.path.join(str(tmp_path), "source.asdf")) as ff,
179+
):
178180
ff.find_references()
179181
assert ff.tree["ref"]._uri == "external.asdf#f~0o~0o~1/a"
180182

asdf/tags/core/external_reference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ExternalArrayReference:
3030
3131
>>> import asdf
3232
>>> ref = asdf.ExternalArrayReference("myfitsfile.fits", 1, "float64", (100, 100))
33-
>>> tree = {'reference': ref}
33+
>>> tree = {"reference": ref}
3434
>>> with asdf.AsdfFile(tree) as ff:
3535
... ff.write_to("test.asdf")
3636

asdf/tags/core/integer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ class IntegerType:
3333
>>> # Store the large integer value to the tree using asdf.IntegerType
3434
>>> tree = dict(largeval=asdf.IntegerType(largeval))
3535
>>> with asdf.AsdfFile(tree) as af:
36-
... af.write_to('largeval.asdf')
37-
>>> with asdf.open('largeval.asdf') as aa:
38-
... assert aa['largeval'] == largeval
36+
... af.write_to("largeval.asdf")
37+
>>> with asdf.open("largeval.asdf") as aa:
38+
... assert aa["largeval"] == largeval
3939
"""
4040

4141
def __init__(self, value, storage_type="internal"):

integration_tests/compatibility/test_file_compatibility.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,10 @@ def test_file_compatibility(asdf_version, env_path, tmp_path):
199199
str(standard_version),
200200
capture_output=True,
201201
), f"asdf library version {asdf_version} failed to generate an ASDF Standard {standard_version} file"
202-
assert_file_correct(old_file_path), (
203-
f"asdf library version {asdf_version} produced an ASDF Standard {standard_version}"
204-
"that this code failed to read"
202+
(
203+
assert_file_correct(old_file_path),
204+
(
205+
f"asdf library version {asdf_version} produced an ASDF Standard {standard_version}"
206+
"that this code failed to read"
207+
),
205208
)

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ target-version = "py310"
160160
line-length = 120
161161
extend-exclude = ["asdf/_extern/*", "asdf/_jsonschema/*", "docs/*"]
162162

163+
[tool.ruff.format]
164+
docstring-code-format = true
165+
docstring-code-line-length = 88
166+
163167
[tool.ruff.lint]
164168
future-annotations = true
165169
select = [

0 commit comments

Comments
 (0)