Skip to content

Commit b068c1b

Browse files
Merge df1aab9 into 1fbc18c
2 parents 1fbc18c + df1aab9 commit b068c1b

21 files changed

+53
-39
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,24 @@ repos:
2424
- id: python-no-log-warn
2525
- id: text-unicode-replacement-char
2626
- repo: https://github.com/asottile/reorder-python-imports
27-
rev: v3.9.0
27+
rev: v3.10.0
2828
hooks:
2929
- id: reorder-python-imports
3030
args: [--py38-plus, --add-import, 'from __future__ import annotations']
3131
- repo: https://github.com/asottile/setup-cfg-fmt
32-
rev: v2.3.0
32+
rev: v2.4.0
3333
hooks:
3434
- id: setup-cfg-fmt
3535
- repo: https://github.com/psf/black
36-
rev: 23.3.0
36+
rev: 23.7.0
3737
hooks:
3838
- id: black
3939
- repo: https://github.com/charliermarsh/ruff-pre-commit
40-
rev: v0.0.270
40+
rev: v0.0.286
4141
hooks:
4242
- id: ruff
4343
- repo: https://github.com/dosisod/refurb
44-
rev: v1.16.0
44+
rev: v1.20.0
4545
hooks:
4646
- id: refurb
4747
args: [--ignore, FURB126]
@@ -52,7 +52,7 @@ repos:
5252
args: [-vv, --fail-under=75]
5353
exclude: ^(tests/|docs/|scripts/)
5454
- repo: https://github.com/pre-commit/mirrors-mypy
55-
rev: 'v1.3.0'
55+
rev: 'v1.5.1'
5656
hooks:
5757
- id: mypy
5858
args: [
@@ -66,7 +66,7 @@ repos:
6666
]
6767
pass_filenames: false
6868
- repo: https://github.com/executablebooks/mdformat
69-
rev: 0.7.16
69+
rev: 0.7.17
7070
hooks:
7171
- id: mdformat
7272
additional_dependencies: [
@@ -76,7 +76,7 @@ repos:
7676
args: [--wrap, "88"]
7777
files: (README\.md)
7878
- repo: https://github.com/executablebooks/mdformat
79-
rev: 0.7.16
79+
rev: 0.7.17
8080
hooks:
8181
- id: mdformat
8282
additional_dependencies: [
@@ -101,7 +101,7 @@ repos:
101101
docs/source/tutorials/set_up_a_project.md
102102
)$
103103
- repo: https://github.com/codespell-project/codespell
104-
rev: v2.2.4
104+
rev: v2.2.5
105105
hooks:
106106
- id: codespell
107107
additional_dependencies: [tomli]

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,7 @@ markers = [
9393
]
9494
norecursedirs = [".idea", ".tox"]
9595
filterwarnings = ["ignore:'@pytask.mark.*. is deprecated:DeprecationWarning"]
96+
97+
98+
[tool.refurb]
99+
python_version = "3.8"

src/_pytask/click.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import inspect
66
from gettext import gettext as _
77
from typing import Any
8+
from typing import ClassVar
89

910
import click
1011
from _pytask import __version__ as version
@@ -55,7 +56,7 @@ def convert(
5556
class _OptionHighlighter(RegexHighlighter):
5657
"""A highlighter for help texts."""
5758

58-
highlights = [
59+
highlights: ClassVar = [
5960
r"(?P<switch>\-\w)\b",
6061
r"(?P<option>\-\-[\w\-]+)",
6162
r"\-\-[\w\-]+(?P<metavar>[ |=][\w\.:]+)",

src/_pytask/collect_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ def _merge_dictionaries(list_of_dicts: list[dict[Any, Any]]) -> dict[Any, Any]:
196196
"""
197197
merged_dict = _union_of_dictionaries(list_of_dicts)
198198

199-
if len(merged_dict) == 1 and isinstance(list(merged_dict)[0], _Placeholder):
200-
placeholder, value = list(merged_dict.items())[0]
199+
if len(merged_dict) == 1 and isinstance(next(iter(merged_dict)), _Placeholder):
200+
placeholder, value = next(iter(merged_dict.items()))
201201
out = value if placeholder.scalar else {0: value}
202202
else:
203203
counter = itertools.count()

src/_pytask/config_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def set_defaults_from_config(
1414
context: click.Context, param: click.Parameter, value: Any # noqa: ARG001
1515
) -> Path | None:
1616
"""Set the defaults for the command-line interface from the configuration."""
17-
# Hack: pytask will later walk through all configuration hooks, even the ones not
18-
# related to this command. They might expect the defaults coming from their related
17+
# pytask will later walk through all configuration hooks, even the ones not related
18+
# to this command. They might expect the defaults coming from their related
1919
# command-line options during parsing. Here, we add their defaults to the
2020
# configuration.
2121
command_option_names = [option.name for option in context.command.params]

src/_pytask/console.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ def create_url_style_for_path(path: Path, edtior_url_scheme: str) -> Style:
210210
)
211211

212212

213-
def _get_file(function: Callable[..., Any], skipped_paths: list[Path] = None) -> Path:
213+
def _get_file(
214+
function: Callable[..., Any], skipped_paths: list[Path] | None = None
215+
) -> Path:
214216
"""Get path to module where the function is defined.
215217
216218
When the ``pdb`` or ``trace`` mode is activated, every task function is wrapped with
@@ -255,7 +257,7 @@ def unify_styles(*styles: str | Style) -> Style:
255257

256258
def create_summary_panel(
257259
counts: dict[Enum, int],
258-
outcome_enum: type[CollectionOutcome] | type[TaskOutcome],
260+
outcome_enum: type[CollectionOutcome | TaskOutcome],
259261
description_total: str,
260262
) -> Panel:
261263
"""Create a summary panel."""

src/_pytask/debugging.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from types import FrameType
88
from types import TracebackType
99
from typing import Any
10+
from typing import ClassVar
1011
from typing import Generator
1112
from typing import TYPE_CHECKING
1213

@@ -111,7 +112,7 @@ class PytaskPDB:
111112

112113
_pluginmanager: pluggy.PluginManager | None = None
113114
_config: dict[str, Any] | None = None
114-
_saved: list[tuple[Any, ...]] = []
115+
_saved: ClassVar[list[tuple[Any, ...]]] = []
115116
_recursive_debug: int = 0
116117
_wrapped_pdb_cls: tuple[type[pdb.Pdb], type[pdb.Pdb]] | None = None
117118

src/_pytask/git.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ def is_git_installed() -> bool:
1515

1616
def cmd_output(*cmd: str, **kwargs: Any) -> tuple[int, str, str]:
1717
"""Execute a command and capture the output."""
18-
r = subprocess.run(cmd, capture_output=True, **kwargs)
18+
r = subprocess.run(cmd, capture_output=True, check=False, **kwargs)
1919
stdout = r.stdout.decode() if r.stdout is not None else None
2020
stderr = r.stderr.decode() if r.stderr is not None else None
2121
return r.returncode, stdout, stderr
2222

2323

2424
def init_repo(path: Path) -> None:
2525
"""Initialize a git repository."""
26-
subprocess.run(("git", "init"), cwd=path)
26+
subprocess.run(("git", "init"), check=False, cwd=path)
2727

2828

2929
def zsplit(s: str) -> list[str]:

src/_pytask/hookspecs.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from typing import TYPE_CHECKING
1212

1313
import click
14-
import networkx
14+
import networkx as nx
1515
import pluggy
1616
from _pytask.models import NodeInfo
1717
from _pytask.node_protocols import MetaNode
@@ -226,7 +226,7 @@ def pytask_dag(session: Session) -> None:
226226

227227

228228
@hookspec(firstresult=True)
229-
def pytask_dag_create_dag(session: Session, tasks: list[Task]) -> networkx.DiGraph:
229+
def pytask_dag_create_dag(session: Session, tasks: list[Task]) -> nx.DiGraph:
230230
"""Create the DAG.
231231
232232
This hook creates the DAG from tasks, dependencies and products. The DAG can be used
@@ -236,7 +236,7 @@ def pytask_dag_create_dag(session: Session, tasks: list[Task]) -> networkx.DiGra
236236

237237

238238
@hookspec
239-
def pytask_dag_modify_dag(session: Session, dag: networkx.DiGraph) -> None:
239+
def pytask_dag_modify_dag(session: Session, dag: nx.DiGraph) -> None:
240240
"""Modify the DAG.
241241
242242
This hook allows to make some changes to the DAG before it is validated and tasks
@@ -246,7 +246,7 @@ def pytask_dag_modify_dag(session: Session, dag: networkx.DiGraph) -> None:
246246

247247

248248
@hookspec(firstresult=True)
249-
def pytask_dag_validate_dag(session: Session, dag: networkx.DiGraph) -> None:
249+
def pytask_dag_validate_dag(session: Session, dag: nx.DiGraph) -> None:
250250
"""Validate the DAG.
251251
252252
This hook validates the DAG. For example, there can be cycles in the DAG if tasks,
@@ -256,7 +256,7 @@ def pytask_dag_validate_dag(session: Session, dag: networkx.DiGraph) -> None:
256256

257257

258258
@hookspec
259-
def pytask_dag_select_execution_dag(session: Session, dag: networkx.DiGraph) -> None:
259+
def pytask_dag_select_execution_dag(session: Session, dag: nx.DiGraph) -> None:
260260
"""Select the subgraph which needs to be executed.
261261
262262
This hook determines which of the tasks have to be re-run because something has
@@ -267,7 +267,7 @@ def pytask_dag_select_execution_dag(session: Session, dag: networkx.DiGraph) ->
267267

268268
@hookspec(firstresult=True)
269269
def pytask_dag_has_node_changed(
270-
session: Session, dag: networkx.DiGraph, node: MetaNode, task_name: str
270+
session: Session, dag: nx.DiGraph, node: MetaNode, task_name: str
271271
) -> None:
272272
"""Select the subgraph which needs to be executed.
273273

src/_pytask/logging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def _format_duration(duration: float) -> str:
129129

130130

131131
def _humanize_time( # noqa: C901, PLR0912
132-
amount: int | float, unit: str, short_label: bool = False
132+
amount: float, unit: str, short_label: bool = False
133133
) -> list[tuple[float, str]]:
134134
"""Humanize the time.
135135

src/_pytask/mark/__init__.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ def select_by_mark(session: Session, dag: nx.DiGraph) -> set[str]: ...
1515

1616
class MARK_GEN: # noqa: N801
1717
@deprecated(
18-
"'@pytask.mark.produces' is deprecated starting pytask v0.4.0 and will be removed in v0.5.0. To upgrade your project to the new syntax, read the tutorial on product and dependencies: https://tinyurl.com/yrezszr4.", # noqa: E501
18+
"'@pytask.mark.produces' is deprecated starting pytask v0.4.0 and will be removed in v0.5.0. To upgrade your project to the new syntax, read the tutorial on product and dependencies: https://tinyurl.com/yrezszr4.", # noqa: E501, PYI053
1919
category=DeprecationWarning,
2020
stacklevel=1,
2121
)
2222
@staticmethod
2323
def produces(objects: PyTree[str | Path]) -> None: ...
2424
@deprecated(
25-
"'@pytask.mark.depends_on' is deprecated starting pytask v0.4.0 and will be removed in v0.5.0. To upgrade your project to the new syntax, read the tutorial on product and dependencies: https://tinyurl.com/yrezszr4.", # noqa: E501
25+
"'@pytask.mark.depends_on' is deprecated starting pytask v0.4.0 and will be removed in v0.5.0. To upgrade your project to the new syntax, read the tutorial on product and dependencies: https://tinyurl.com/yrezszr4.", # noqa: E501, PYI053
2626
category=DeprecationWarning,
2727
stacklevel=1,
2828
)

src/_pytask/mark/expression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def evaluate(self, matcher: Callable[[str], bool]) -> bool:
244244
Whether the expression matches or not.
245245
246246
"""
247-
ret: bool = eval( # noqa: PGH001
247+
ret: bool = eval( # noqa: PGH001, S307
248248
self.code, {"__builtins__": {}}, MatcherAdapter(matcher)
249249
)
250250
return ret

src/_pytask/outcomes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def style_textonly(self) -> str:
168168

169169
def count_outcomes(
170170
reports: Sequence[CollectionReport | ExecutionReport],
171-
outcome_enum: type[CollectionOutcome] | type[TaskOutcome],
171+
outcome_enum: type[CollectionOutcome | TaskOutcome],
172172
) -> dict[Enum, int]:
173173
"""Count how often an outcome occurred.
174174

src/_pytask/shared.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ def parse_paths(x: Any | None) -> list[Path] | None:
4949
if x is not None:
5050
paths = [Path(p) for p in to_list(x)]
5151
paths = [
52-
Path(p).resolve() for path in paths for p in glob.glob(path.as_posix())
52+
Path(p).resolve()
53+
for path in paths
54+
for p in glob.glob(path.as_posix()) # noqa: PTH207
5355
]
5456
out = paths
5557
else:

src/_pytask/task_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def parse_collected_tasks_with_task_marker(
118118
for unique_name, task in names_to_functions.items():
119119
collected_tasks[unique_name] = task
120120
else:
121-
collected_tasks[name] = [i[1] for i in parsed_tasks if i[0] == name][0]
121+
collected_tasks[name] = next(i[1] for i in parsed_tasks if i[0] == name)
122122

123123
return collected_tasks
124124

tests/test_capture.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def test_captureresult() -> None:
331331
assert err == "err"
332332
assert cr[0] == "out"
333333
assert cr[1] == "err"
334-
assert cr == cr
334+
assert cr == cr # noqa: PLR0124
335335
assert cr == CaptureResult("out", "err")
336336
assert cr != CaptureResult("wrong", "err")
337337
assert cr == ("out", "err")

tests/test_clean.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ def git_project(request, tmp_path):
7171

7272
init_repo(tmp_path)
7373
subprocess.run(
74-
("git", "add", "task_module.py", "in_tracked.txt", "tracked.txt"), cwd=tmp_path
74+
("git", "add", "task_module.py", "in_tracked.txt", "tracked.txt"),
75+
cwd=tmp_path,
76+
check=False,
7577
)
76-
subprocess.run(("git", "commit", "-m", "'COMMIT'"), cwd=tmp_path)
78+
subprocess.run(("git", "commit", "-m", "'COMMIT'"), cwd=tmp_path, check=False)
7779

7880
return tmp_path
7981

tests/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
@pytest.mark.end_to_end()
1212
def test_version_option():
13-
process = subprocess.run(["pytask", "--version"], capture_output=True)
13+
process = subprocess.run(["pytask", "--version"], capture_output=True, check=False)
1414
assert "pytask, version " + __version__ in process.stdout.decode("utf-8")
1515

1616

tests/test_execute.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
@pytest.mark.end_to_end()
2222
def test_python_m_pytask(tmp_path):
2323
tmp_path.joinpath("task_module.py").write_text("def task_example(): pass")
24-
subprocess.run(["python", "-m", "pytask", tmp_path.as_posix()], check=True)
24+
subprocess.run(["python", "-m", "pytask", tmp_path.as_posix()], check=False)
2525

2626

2727
@pytest.mark.end_to_end()

tests/test_mark.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,9 @@ def task_write_text(depends_on, produces):
371371
tmp_path.joinpath("in.txt").touch()
372372

373373
result = subprocess.run(
374-
("pytest", tmp_path.joinpath("task_module.py").as_posix()), capture_output=True
374+
("pytest", tmp_path.joinpath("task_module.py").as_posix()),
375+
capture_output=True,
376+
check=False,
375377
)
376378
assert b"DeprecationWarning: '@pytask.mark.depends_on'" in result.stdout
377379
assert b"DeprecationWarning: '@pytask.mark.produces'" in result.stdout

tests/test_warnings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def warn_now():
155155
path_to_warn_module.write_text(textwrap.dedent(warn_module))
156156

157157
# Cannot use runner since then warnings are not ignored by default.
158-
result = subprocess.run(("pytask"), cwd=tmp_path, capture_output=True)
158+
result = subprocess.run(("pytask"), cwd=tmp_path, capture_output=True, check=False)
159159

160160
assert result.returncode == ExitCode.OK
161161
assert "Warnings" not in result.stdout.decode()

0 commit comments

Comments
 (0)