Skip to content

Commit ca53e5b

Browse files
[pre-commit.ci] pre-commit autoupdate (#33)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Tobias Raabe <[email protected]>
1 parent 6e9f62a commit ca53e5b

14 files changed

+56
-123
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
3+
rev: v4.6.0
44
hooks:
55
- id: check-added-large-files
6-
args:
7-
- --maxkb=25
6+
args: [--maxkb=25]
87
- id: check-case-conflict
98
- id: check-merge-conflict
109
- id: check-vcs-permalinks
@@ -14,9 +13,7 @@ repos:
1413
- id: fix-byte-order-marker
1514
- id: mixed-line-ending
1615
- id: no-commit-to-branch
17-
args:
18-
- --branch
19-
- main
16+
args: [--branch, main]
2017
- id: trailing-whitespace
2118
- repo: https://github.com/pre-commit/pygrep-hooks
2219
rev: v1.10.0
@@ -27,89 +24,33 @@ repos:
2724
- id: python-no-log-warn
2825
- id: python-use-type-annotations
2926
- id: text-unicode-replacement-char
30-
- repo: https://github.com/asottile/reorder-python-imports
31-
rev: v3.12.0
32-
hooks:
33-
- id: reorder-python-imports
34-
args:
35-
- --py38-plus
36-
- --add-import
37-
- from __future__ import annotations
3827
- repo: https://github.com/asottile/setup-cfg-fmt
3928
rev: v2.5.0
4029
hooks:
4130
- id: setup-cfg-fmt
42-
- repo: https://github.com/PyCQA/docformatter
43-
rev: v1.7.5
44-
hooks:
45-
- id: docformatter
46-
args:
47-
- --in-place
48-
- --wrap-summaries
49-
- '88'
50-
- --wrap-descriptions
51-
- '88'
52-
- --blank
53-
- repo: https://github.com/psf/black
54-
rev: 23.9.1
55-
hooks:
56-
- id: black
5731
- repo: https://github.com/astral-sh/ruff-pre-commit
58-
rev: v0.0.292
32+
rev: v0.4.4
5933
hooks:
6034
- id: ruff
35+
- id: ruff-format
6136
- repo: https://github.com/dosisod/refurb
62-
rev: v1.21.0
37+
rev: v2.0.0
6338
hooks:
6439
- id: refurb
65-
args:
66-
- --ignore
67-
- FURB126
68-
- repo: https://github.com/econchick/interrogate
69-
rev: 1.5.0
70-
hooks:
71-
- id: interrogate
72-
args:
73-
- -v
74-
- --fail-under=40
75-
- src
76-
- tests
7740
- repo: https://github.com/executablebooks/mdformat
7841
rev: 0.7.17
7942
hooks:
8043
- id: mdformat
8144
additional_dependencies:
8245
- mdformat-gfm
8346
- mdformat-black
84-
args:
85-
- --wrap
86-
- '88'
47+
args: [--wrap, "88"]
8748
- repo: https://github.com/codespell-project/codespell
8849
rev: v2.2.6
8950
hooks:
9051
- id: codespell
91-
- repo: https://github.com/pre-commit/mirrors-mypy
92-
rev: v1.5.1
93-
hooks:
94-
- id: mypy
95-
args:
96-
- --no-strict-optional
97-
- --ignore-missing-imports
98-
additional_dependencies:
99-
- attrs
100-
- click
101-
- types-setuptools
102-
pass_filenames: false
103-
- repo: https://github.com/mgedmin/check-manifest
104-
rev: '0.49'
105-
hooks:
106-
- id: check-manifest
107-
args:
108-
- --no-build-isolation
109-
additional_dependencies:
110-
- setuptools-scm
111-
- toml
11252
- repo: meta
11353
hooks:
11454
- id: check-hooks-apply
11555
- id: check-useless-excludes
56+
# - id: identity # Prints all files passed to pre-commits. Debugging.

pyproject.toml

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"]
33
build-backend = "setuptools.build_meta"
44

5-
65
[tool.setuptools_scm]
76
write_to = "src/pytask_stata/_version.py"
87

9-
108
[tool.mypy]
119
files = ["src", "tests"]
1210
check_untyped_defs = true
@@ -17,54 +15,36 @@ no_implicit_optional = true
1715
warn_redundant_casts = true
1816
warn_unused_ignores = true
1917

20-
2118
[[tool.mypy.overrides]]
2219
module = "tests.*"
2320
disallow_untyped_defs = false
2421
ignore_errors = true
2522

26-
2723
[tool.ruff]
2824
target-version = "py38"
29-
select = ["ALL"]
3025
fix = true
31-
extend-ignore = [
32-
"I", # ignore isort
33-
"TRY",
34-
# Numpy docstyle
35-
"D107",
36-
"D203",
37-
"D212",
38-
"D213",
39-
"D402",
40-
"D413",
41-
"D415",
42-
"D416",
43-
"D417",
44-
# Others.
45-
"D404", # Do not start module docstring with "This".
46-
"RET504", # unnecessary variable assignment before return.
47-
"S101", # raise errors for asserts.
48-
"B905", # strict parameter for zip that was implemented in py310.
49-
"ANN101", # type annotating self
50-
"ANN102", # type annotating cls
51-
"FBT", # flake8-boolean-trap
52-
"EM", # flake8-errmsg
53-
"ANN401", # flake8-annotate typing.Any
54-
"PD", # pandas-vet
55-
"COM812", # trailing comma missing, but black takes care of that
56-
]
26+
unsafe-fixes = true
5727

28+
[tool.ruff.lint]
29+
select = ["ALL"]
30+
ignore = [
31+
"ANN101",
32+
"ANN102",
33+
"ANN401", # flake8-annotate typing.Any
34+
"COM812", # Comply with ruff-format.
35+
"ISC001", # Comply with ruff-format.
36+
]
5837

59-
[tool.ruff.per-file-ignores]
60-
"tests/*" = ["D", "ANN"]
38+
[tool.ruff.lint.per-file-ignores]
39+
"tests/*" = ["D", "ANN", "S101"]
6140
"__init__.py" = ["D104"]
6241

42+
[tool.ruff.lint.isort]
43+
force-single-line = true
6344

64-
[tool.ruff.pydocstyle]
45+
[tool.ruff.lint.pydocstyle]
6546
convention = "numpy"
6647

67-
6848
[tool.pytest.ini_options]
6949
# Do not add src since it messes with the loading of pytask-parallel as a plugin.
7050
testpaths = ["tests"]

src/pytask_stata/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Everything related to the CLI."""
2+
23
from __future__ import annotations
34

45
import click

src/pytask_stata/collect.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
"""Collect tasks."""
2+
23
from __future__ import annotations
34

45
import functools
56
import subprocess
67
from types import FunctionType
7-
from typing import Any
88
from typing import TYPE_CHECKING
9+
from typing import Any
910

11+
from pytask import Mark
12+
from pytask import Session
13+
from pytask import Task
1014
from pytask import depends_on
1115
from pytask import has_mark
1216
from pytask import hookimpl
13-
from pytask import Mark
1417
from pytask import parse_nodes
1518
from pytask import produces
1619
from pytask import remove_marks
17-
from pytask import Session
18-
from pytask import Task
20+
1921
from pytask_stata.shared import convert_task_id_to_name_of_log_file
2022
from pytask_stata.shared import stata
2123

@@ -47,10 +49,11 @@ def pytask_collect_task(
4749
obj, marks = remove_marks(obj, "stata")
4850

4951
if len(marks) > 1:
50-
raise ValueError(
52+
msg = (
5153
f"Task {name!r} has multiple @pytask.mark.stata marks, but only one is "
5254
"allowed."
5355
)
56+
raise ValueError(msg)
5457

5558
mark = _parse_stata_mark(mark=marks[0])
5659
script, options = stata(**marks[0].kwargs)
@@ -109,8 +112,7 @@ def _parse_stata_mark(mark: Mark) -> Mark:
109112

110113
parsed_kwargs = {"script": script or None, "options": options or []}
111114

112-
mark = Mark("stata", (), parsed_kwargs)
113-
return mark
115+
return Mark("stata", (), parsed_kwargs)
114116

115117

116118
def _copy_func(func: FunctionType) -> FunctionType:

src/pytask_stata/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
"""Configure pytask."""
2+
23
from __future__ import annotations
34

45
import shutil
56
import sys
67
from typing import Any
78

89
from pytask import hookimpl
10+
911
from pytask_stata.shared import STATA_COMMANDS
1012

1113

src/pytask_stata/execute.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
"""Execute tasks."""
2+
23
from __future__ import annotations
34

45
import re
56

6-
from pytask import has_mark
7-
from pytask import hookimpl
87
from pytask import Session
98
from pytask import Task
10-
from pytask_stata.shared import convert_task_id_to_name_of_log_file
9+
from pytask import has_mark
10+
from pytask import hookimpl
11+
1112
from pytask_stata.shared import STATA_COMMANDS
13+
from pytask_stata.shared import convert_task_id_to_name_of_log_file
1214

1315

1416
@hookimpl
1517
def pytask_execute_task_setup(session: Session, task: Task) -> None:
1618
"""Check if Stata is found on the PATH."""
1719
if has_mark(task, "stata") and session.config["stata"] is None:
18-
raise RuntimeError(
20+
msg = (
1921
"Stata is needed to run do-files, but it is not found on your PATH.\n\n"
2022
f"We are looking for one of {STATA_COMMANDS} on your PATH. If you have a"
2123
"different Stata executable, please, file an issue at "
2224
"https://github.com/pytask-dev/pytask-stata."
2325
)
26+
raise RuntimeError(msg)
2427

2528

2629
@hookimpl

src/pytask_stata/parametrize.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Parametrize tasks."""
2+
23
from __future__ import annotations
34

45
from typing import Any

src/pytask_stata/plugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
"""Register hook specifications and implementations."""
2+
23
from __future__ import annotations
34

45
from typing import TYPE_CHECKING
56

67
from _pytask.config import hookimpl
8+
79
from pytask_stata import cli
810
from pytask_stata import collect
911
from pytask_stata import config

src/pytask_stata/shared.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
"""Shared functions and variables."""
2+
23
from __future__ import annotations
34

45
import sys
6+
from typing import TYPE_CHECKING
57
from typing import Any
68
from typing import Iterable
79
from typing import Sequence
8-
from typing import TYPE_CHECKING
910

1011
if TYPE_CHECKING:
1112
from pathlib import Path
@@ -78,9 +79,7 @@ def convert_task_id_to_name_of_log_file(id_: str) -> str:
7879
'task_example_py_task_example[arg1]'
7980
8081
"""
81-
id_without_parent_directories = id_.rsplit("/")[-1]
82-
converted_id = id_without_parent_directories.replace(".", "_").replace("::", "_")
83-
return converted_id
82+
return id_.rsplit("/")[-1].replace(".", "_").replace("::", "_")
8483

8584

8685
def _to_list(scalar_or_iter: Any) -> list[Any]:

tests/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from click.testing import CliRunner
77
from pytask_stata.config import STATA_COMMANDS
88

9-
109
needs_stata = pytest.mark.skipif(
1110
next(
1211
(executable for executable in STATA_COMMANDS if shutil.which(executable)), None

0 commit comments

Comments
 (0)