Skip to content

Commit 8be5cbf

Browse files
authored
Improve infra and add step for type checking. (#605)
1 parent 2756d47 commit 8be5cbf

File tree

6 files changed

+71
-87
lines changed

6 files changed

+71
-87
lines changed

.github/workflows/main.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ on:
1515

1616
jobs:
1717

18-
build-package:
19-
name: Build & verify package
18+
run-type-checking:
19+
20+
name: Run tests for type-checking
2021
runs-on: ubuntu-latest
2122

2223
steps:
2324
- uses: actions/checkout@v4
25+
- uses: actions/setup-python@v5
2426
with:
25-
fetch-depth: 0
26-
27-
- uses: hynek/build-and-inspect-python-package@v2
28-
id: baipp
29-
30-
outputs:
31-
python-versions: ${{ steps.baipp.outputs.supported_python_classifiers_json_array }}
27+
python-version-file: .python-version
28+
allow-prereleases: true
29+
cache: pip
30+
- run: pip install tox-uv
31+
- run: tox -e typing
3232

3333
run-tests:
3434

.pre-commit-config.yaml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ repos:
2424
- id: python-check-mock-methods
2525
- id: python-no-log-warn
2626
- id: text-unicode-replacement-char
27-
# - repo: https://github.com/tox-dev/pyproject-fmt
28-
# rev: 1.2.0
29-
# hooks:
30-
# - id: pyproject-fmt
3127
- repo: https://github.com/aio-libs/sort-all
3228
rev: v1.2.0
3329
hooks:
@@ -37,26 +33,10 @@ repos:
3733
hooks:
3834
- id: ruff-format
3935
- id: ruff
40-
args: [--unsafe-fixes]
4136
- repo: https://github.com/dosisod/refurb
4237
rev: v2.0.0
4338
hooks:
4439
- id: refurb
45-
args: [--ignore, FURB126]
46-
- repo: https://github.com/pre-commit/mirrors-mypy
47-
rev: v1.9.0
48-
hooks:
49-
- id: mypy
50-
additional_dependencies: [
51-
attrs>=21.3.0,
52-
click,
53-
optree,
54-
pluggy>=1.3.0,
55-
rich,
56-
sqlalchemy>2,
57-
types-setuptools,
58-
]
59-
pass_filenames: false
6040
- repo: https://github.com/executablebooks/mdformat
6141
rev: 0.7.17
6242
hooks:
@@ -77,11 +57,6 @@ repos:
7757
mdformat-pyproject,
7858
]
7959
files: (docs/.)
80-
- repo: https://github.com/nbQA-dev/nbQA
81-
rev: 1.8.5
82-
hooks:
83-
- id: nbqa-mypy
84-
args: [--ignore-missing-imports]
8560
- repo: https://github.com/kynan/nbstripout
8661
rev: 0.7.1
8762
hooks:

docs/source/changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and
4646
- {pull}`600` refactors test using subprocesses.
4747
- {pull}`603` fixes an example in the documentation about capturing warnings.
4848
- {pull}`604` fixes some examples with `PythonNode`s in the documentation.
49+
- {pull}`605` improves checks and CI.
4950

5051
## 0.4.7 - 2024-03-19
5152

docs_src/tutorials/using_a_data_catalog_5_py310_return.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@
88
def task_transform_csv(
99
path: Annotated[Path, data_catalog["csv"]],
1010
) -> Annotated[pd.DataFrame, data_catalog["transformed_csv"]]:
11-
df = pd.read_csv(path)
11+
return pd.read_csv(path)
1212
# ... transform the data
13-
return df

pyproject.toml

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
[project]
22
name = "pytask"
3-
description = "In its highest aspirations, pytask tries to be pytest as a build system."
3+
description = "pytask is a workflow management system that facilitates reproducible data analyses."
44
requires-python = ">=3.8"
55
classifiers = [
6-
"Development Status :: 4 - Beta",
7-
"Environment :: Console",
8-
"Intended Audience :: Science/Research",
9-
"License :: OSI Approved :: MIT License",
10-
"Operating System :: MacOS :: MacOS X",
11-
"Operating System :: Microsoft :: Windows",
12-
"Operating System :: POSIX",
13-
"Programming Language :: Python :: 3 :: Only",
14-
"Programming Language :: Python :: 3.8",
15-
"Programming Language :: Python :: 3.9",
16-
"Programming Language :: Python :: 3.10",
17-
"Programming Language :: Python :: 3.11",
18-
"Programming Language :: Python :: 3.12",
19-
"Topic :: Scientific/Engineering",
20-
"Topic :: Software Development :: Build Tools",
6+
"Development Status :: 4 - Beta",
7+
"Environment :: Console",
8+
"Intended Audience :: Science/Research",
9+
"License :: OSI Approved :: MIT License",
10+
"Operating System :: MacOS :: MacOS X",
11+
"Operating System :: Microsoft :: Windows",
12+
"Operating System :: POSIX",
13+
"Programming Language :: Python :: 3 :: Only",
14+
"Programming Language :: Python :: 3.8",
15+
"Programming Language :: Python :: 3.9",
16+
"Programming Language :: Python :: 3.10",
17+
"Programming Language :: Python :: 3.11",
18+
"Programming Language :: Python :: 3.12",
19+
"Topic :: Scientific/Engineering",
20+
"Topic :: Software Development :: Build Tools",
2121
]
2222
dynamic = ["version"]
2323
dependencies = [
@@ -48,18 +48,19 @@ email = "raabe@posteo.de"
4848

4949
[project.optional-dependencies]
5050
docs = [
51-
"furo",
52-
"ipython",
53-
"matplotlib",
54-
"myst-parser",
55-
"nbsphinx",
56-
"sphinx",
57-
"sphinx-click",
58-
"sphinx-copybutton",
59-
"sphinx-design>=0.3",
60-
"sphinx-toolbox",
61-
"sphinxext-opengraph",
51+
"furo",
52+
"ipython",
53+
"matplotlib",
54+
"myst-parser",
55+
"nbsphinx",
56+
"sphinx",
57+
"sphinx-click",
58+
"sphinx-copybutton",
59+
"sphinx-design>=0.3",
60+
"sphinx-toolbox",
61+
"sphinxext-opengraph",
6262
]
63+
plugin-list = ["httpx", "tabulate[widechars]", "tqdm"]
6364
test = [
6465
"deepdiff",
6566
"nbmake",
@@ -68,15 +69,10 @@ test = [
6869
"pytest-cov",
6970
"pytest-xdist",
7071
"syrupy",
71-
# For HTTPPath tests.
72-
"aiohttp",
72+
"aiohttp", # For HTTPPath tests.
7373
"coiled",
7474
]
75-
plugin-list = [
76-
"httpx>=0.27.0",
77-
"tabulate[widechars]>=0.9.0",
78-
"tqdm>=4.66.2",
79-
]
75+
typing = ["mypy>=1.9.0", "nbqa[mypy]>=1.8.5"]
8076

8177
[project.urls]
8278
Changelog = "https://pytask-dev.readthedocs.io/en/stable/changes.html"
@@ -94,7 +90,7 @@ build-backend = "hatchling.build"
9490

9591
[tool.rye]
9692
managed = true
97-
dev-dependencies = []
93+
dev-dependencies = ["tox-uv>=1.7.0"]
9894

9995
[tool.hatch.build.hooks.vcs]
10096
version-file = "src/_pytask/_version.py"
@@ -124,15 +120,15 @@ select = ["ALL"]
124120
ignore = [
125121
"ANN101",
126122
"ANN102",
127-
"ANN401", # flake8-annotate typing.Any
128-
"COM812", # Comply with ruff-format.
129-
"ISC001", # Comply with ruff-format.
123+
"ANN401", # flake8-annotate typing.Any
124+
"COM812", # Comply with ruff-format.
125+
"ISC001", # Comply with ruff-format.
130126
"FBT",
131127
"PD901", # Avoid generic df for dataframes.
132-
"S101", # raise errors for asserts.
133-
"S603", # Call check with subprocess.run.
134-
"S607", # Call subprocess.run with partial executable path.
135-
"SLF001", # access private members.
128+
"S101", # raise errors for asserts.
129+
"S603", # Call check with subprocess.run.
130+
"S607", # Call subprocess.run with partial executable path.
131+
"SLF001", # access private members.
136132
]
137133

138134
[tool.ruff.lint.per-file-ignores]
@@ -148,10 +144,13 @@ ignore = [
148144
"docs/source/conf.py" = ["D401", "INP001"]
149145
"docs_src/*" = ["ARG001", "D", "INP001", "S301"]
150146
"docs_src/*/*.py" = ["FA100", "FA102", "PLR2004", "TCH"]
151-
"docs/source/how_to_guides/functional_interface*" = ["B018", "D", "INP", "ARG005"]
147+
"docs/source/how_to_guides/functional_interface*" = [
148+
"B018",
149+
"D",
150+
"INP",
151+
"ARG005",
152+
]
152153
"docs_src/how_to_guides/using_task_returns_*_task.py" = ["ARG005", "E731"]
153-
"docs_src/how_to_guides/writing_custom_nodes_*.py" = ["S301"]
154-
"docs_src/tutorials/using_a_data_catalog_*.py" = ["RET504"]
155154

156155
[tool.ruff.lint.isort]
157156
force-single-line = true
@@ -191,6 +190,10 @@ ignore_errors = true
191190
module = ["click_default_group", "networkx"]
192191
ignore_missing_imports = true
193192

193+
[[tool.mypy.overrides]]
194+
module = ["_pytask.coiled_utils"]
195+
disable_error_code = ["import-not-found"]
196+
194197
[[tool.mypy.overrides]]
195198
module = ["_pytask.hookspecs"]
196199
disable_error_code = ["empty-body"]

tox.ini

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,21 @@ envlist = docs, test
66
passenv = CI
77
package = editable
88

9+
[testenv:docs]
10+
extras = docs, test
11+
commands =
12+
- sphinx-build -n -T -b html -d {envtmpdir}/doctrees docs/source docs/build/html
13+
- sphinx-build -n -T -b doctest -d {envtmpdir}/doctrees docs/source docs/build/html
14+
15+
[testenv:typing]
16+
extras = typing
17+
commands =
18+
mypy
19+
nbqa mypy --ignore-missing-imports .
20+
921
[testenv:test]
1022
extras = test
1123
deps =
1224
pygraphviz;platform_system != "Windows"
1325
commands =
1426
pytest --nbmake {posargs}
15-
16-
[testenv:docs]
17-
extras = docs, test
18-
commands =
19-
- sphinx-build -n -T -b html -d {envtmpdir}/doctrees docs/source docs/build/html
20-
- sphinx-build -n -T -b doctest -d {envtmpdir}/doctrees docs/source docs/build/html

0 commit comments

Comments
 (0)