Skip to content

Commit 1c76085

Browse files
authored
Switch from black to ruff-format. (#478)
1 parent 14bc796 commit 1c76085

17 files changed

+42
-23
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,12 @@ repos:
4444
rev: v1.2.0
4545
hooks:
4646
- id: sort-all
47-
- repo: https://github.com/psf/black
48-
rev: 23.10.1
49-
hooks:
50-
- id: black
5147
- repo: https://github.com/astral-sh/ruff-pre-commit
5248
rev: v0.1.4
5349
hooks:
5450
- id: ruff
5551
args: [--unsafe-fixes]
52+
- id: ruff-format
5653
- repo: https://github.com/dosisod/refurb
5754
rev: v1.22.1
5855
hooks:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ______________________________________________________________________
1717
[![image](https://img.shields.io/github/actions/workflow/status/pytask-dev/pytask/main.yml?branch=main)](https://github.com/pytask-dev/pytask/actions?query=branch%3Amain)
1818
[![image](https://codecov.io/gh/pytask-dev/pytask/branch/main/graph/badge.svg)](https://app.codecov.io/gh/pytask-dev/pytask)
1919
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/pytask-dev/pytask/main.svg)](https://results.pre-commit.ci/latest/github/pytask-dev/pytask/main)
20-
[![image](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
20+
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
2121

2222
<!-- Keep in sync with docs/source/index.md -->
2323

docs/source/changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and
2424
- {pull}`472` adds `is_product` to {meth}`PNode.load`.
2525
- {pull}`473` adds signatures to nodes which decouples an identifier from a name.
2626
- {pull}`477` updates the PyPI action.
27+
- {pull}`478` replaces black with ruff-format.
2728

2829
## 0.4.1 - 2023-10-11
2930

docs/source/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
[![image](https://img.shields.io/github/actions/workflow/status/pytask-dev/pytask/main.yml?branch=main)](https://github.com/pytask-dev/pytask/actions?query=branch%3Amain)
1212
[![image](https://codecov.io/gh/pytask-dev/pytask/branch/main/graph/badge.svg)](https://app.codecov.io/gh/pytask-dev/pytask)
1313
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/pytask-dev/pytask/main.svg)](https://results.pre-commit.ci/latest/github/pytask-dev/pytask/main)
14-
[![image](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
14+
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
1515

1616
## Features
1717

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ dependencies:
2323
- typing_extensions
2424

2525
# Misc
26-
- black
2726
- deepdiff
2827
- ipywidgets
2928
- jupyterlab
@@ -35,6 +34,7 @@ dependencies:
3534
- pytest-cov
3635
- pytest-env
3736
- pytest-xdist
37+
- ruff
3838
- syrupy
3939
- tabulate
4040
- tox

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ ignore = [
110110
"D416",
111111
"D417",
112112
# Others.
113+
"ISC001",
113114
"S101", # raise errors for asserts.
114115
"ANN101", # type annotating self
115116
"ANN102", # type annotating cls

src/_pytask/click.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ class ColoredGroup(DefaultGroup):
6767
"""A command group with colored help pages."""
6868

6969
def format_help(
70-
self: DefaultGroup, ctx: click.Context, formatter: Any # noqa: ARG002
70+
self: DefaultGroup,
71+
ctx: click.Context,
72+
formatter: Any, # noqa: ARG002
7173
) -> None:
7274
"""Format the help text."""
7375
highlighter = _OptionHighlighter()
@@ -116,7 +118,9 @@ class ColoredCommand(click.Command):
116118
"""A command with colored help pages."""
117119

118120
def format_help(
119-
self: click.Command, ctx: click.Context, formatter: Any # noqa: ARG002
121+
self: click.Command,
122+
ctx: click.Context,
123+
formatter: Any, # noqa: ARG002
120124
) -> None:
121125
"""Format the help text."""
122126
console.print(

src/_pytask/config_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020

2121

2222
def set_defaults_from_config(
23-
context: click.Context, param: click.Parameter, value: Any # noqa: ARG001
23+
context: click.Context,
24+
param: click.Parameter, # noqa: ARG001
25+
value: Any,
2426
) -> Path | None:
2527
"""Set the defaults for the command-line interface from the configuration."""
2628
# pytask will later walk through all configuration hooks, even the ones not related

src/_pytask/debugging.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ def pytask_extend_command_line_interface(cli: click.Group) -> None:
5959

6060

6161
def _pdbcls_callback(
62-
ctx: click.Context, name: str, value: str | None # noqa: ARG001
62+
ctx: click.Context, # noqa: ARG001
63+
name: str, # noqa: ARG001
64+
value: str | None,
6365
) -> tuple[str, str] | None:
6466
"""Validate the debugger class string passed to pdbcls."""
6567
message = "'pdbcls' must be like IPython.terminal.debugger:TerminalPdb"
@@ -259,7 +261,10 @@ def get_stack(self, f: FrameType, t: TracebackType) -> tuple[str, int]:
259261

260262
@classmethod
261263
def _init_pdb(
262-
cls, method: str, *args: Any, **kwargs: Any # noqa: ARG003
264+
cls,
265+
method: str,
266+
*args: Any, # noqa: ARG003
267+
**kwargs: Any,
263268
) -> pdb.Pdb:
264269
"""Initialize PDB debugging, dropping any IO capturing."""
265270
if cls._pluginmanager is None:

src/_pytask/parameters.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@
7272

7373

7474
def _database_url_callback(
75-
ctx: Context, name: str, value: str | None # noqa: ARG001
75+
ctx: Context, # noqa: ARG001
76+
name: str, # noqa: ARG001
77+
value: str | None,
7678
) -> URL | None:
7779
"""Check the url for the database."""
7880
# Since sqlalchemy v2.0.19, we need to shortcircuit here.

src/_pytask/path.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,9 @@ def shorten_path(path: Path, paths: Sequence[Path]) -> str:
217217

218218
@HashPathCache.memoize
219219
def hash_path(
220-
path: Path, modification_time: float, digest: str = "sha256" # noqa: ARG001
220+
path: Path,
221+
modification_time: float, # noqa: ARG001
222+
digest: str = "sha256",
221223
) -> str:
222224
"""Compute the hash of a file.
223225

tests/test_clean.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ def test_dont_remove_files_tracked_by_git(runner, git_project):
283283
@pytest.mark.end_to_end()
284284
def test_clean_git_files_if_git_is_not_installed(monkeypatch, runner, git_project):
285285
monkeypatch.setattr(
286-
"_pytask.clean.is_git_installed", lambda *x: False # noqa: ARG005
286+
"_pytask.clean.is_git_installed",
287+
lambda *x: False, # noqa: ARG005
287288
)
288289

289290
result = runner.invoke(cli, ["clean", git_project.as_posix()])

tests/test_collect_utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ def _convert_placeholders_to_tuples(x):
7272
return {
7373
(next(counter), k.scalar)
7474
if isinstance(k, _Placeholder)
75-
else k: _convert_placeholders_to_tuples(v)
76-
if isinstance(v, dict)
77-
else v
75+
else k: _convert_placeholders_to_tuples(v) if isinstance(v, dict) else v
7876
for k, v in x.items()
7977
}
8078

tests/test_dag_command.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ def test_raise_error_with_graph_via_cli_missing_optional_program(
177177
monkeypatch, tmp_path, runner
178178
):
179179
monkeypatch.setattr(
180-
"_pytask.compat.importlib.import_module", lambda x: None # noqa: ARG005
180+
"_pytask.compat.importlib.import_module",
181+
lambda x: None, # noqa: ARG005
181182
)
182183
monkeypatch.setattr("_pytask.compat.shutil.which", lambda x: None) # noqa: ARG005
183184

@@ -207,7 +208,8 @@ def test_raise_error_with_graph_via_task_missing_optional_program(
207208
monkeypatch, tmp_path, runner
208209
):
209210
monkeypatch.setattr(
210-
"_pytask.compat.importlib.import_module", lambda x: None # noqa: ARG005
211+
"_pytask.compat.importlib.import_module",
212+
lambda x: None, # noqa: ARG005
211213
)
212214
monkeypatch.setattr("_pytask.compat.shutil.which", lambda x: None) # noqa: ARG005
213215

tests/test_git.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
@pytest.mark.parametrize(("mock_return", "expected"), [(True, True), (None, False)])
99
def test_is_git_installed(monkeypatch, mock_return, expected):
1010
monkeypatch.setattr(
11-
"_pytask.git.shutil.which", lambda *x: mock_return # noqa: ARG005
11+
"_pytask.git.shutil.which",
12+
lambda *x: mock_return, # noqa: ARG005
1213
)
1314
result = is_git_installed()
1415
assert result is expected

tests/test_path.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ def test_no_meta_path_found(
170170
del sys.modules[module.__name__]
171171

172172
monkeypatch.setattr(
173-
importlib.util, "spec_from_file_location", lambda *args: None # noqa: ARG005
173+
importlib.util,
174+
"spec_from_file_location",
175+
lambda *args: None, # noqa: ARG005
174176
)
175177
with pytest.raises(ImportError):
176178
import_path(simple_module, root=tmp_path)

tests/test_persist.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ def task_dummy(depends_on, produces):
123123
)
124124
def test_pytask_execute_task_process_report(monkeypatch, exc_info, expected):
125125
monkeypatch.setattr(
126-
"_pytask.persist.update_states_in_database", lambda *x: None # noqa: ARG005
126+
"_pytask.persist.update_states_in_database",
127+
lambda *x: None, # noqa: ARG005
127128
)
128129

129130
task = DummyClass()

0 commit comments

Comments
 (0)