Skip to content

Commit 2671317

Browse files
committed
Merge remote-tracking branch 'origin/main' into pre-commit-ci-update-config
2 parents 2880647 + 83595aa commit 2671317

8 files changed

Lines changed: 98 additions & 66 deletions

File tree

.github/workflows/main.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ jobs:
2121
runs-on: ubuntu-latest
2222

2323
steps:
24-
- uses: actions/checkout@v4
24+
- uses: actions/checkout@v5
2525
- uses: astral-sh/setup-uv@v6
2626
with:
2727
enable-cache: true
28-
- run: uv run --no-dev --group typing mypy
29-
- run: uv run --no-dev --group typing nbqa mypy --ignore-missing-imports .
28+
- name: Install just
29+
uses: extractions/setup-just@v3
30+
- run: just typing
31+
- run: just typing-nb
3032

3133
run-tests:
3234

@@ -40,11 +42,13 @@ jobs:
4042
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
4143

4244
steps:
43-
- uses: actions/checkout@v4
45+
- uses: actions/checkout@v5
4446
- uses: astral-sh/setup-uv@v6
4547
with:
46-
python-version: ${{ matrix.python-version }}
4748
enable-cache: true
49+
python-version: ${{ matrix.python-version }}
50+
- name: Install just
51+
uses: extractions/setup-just@v3
4852

4953
- if: matrix.os == 'ubuntu-latest'
5054
run: |
@@ -53,15 +57,15 @@ jobs:
5357
5458
- name: Run tests, doctests, and notebook tests
5559
shell: bash -l {0}
56-
run: uv run --group test pytest --nbmake --cov=src --cov=tests --cov-report=xml -n auto
60+
run: just test-cov
5761

5862
- name: Upload test coverage reports to Codecov with GitHub Action
5963
uses: codecov/codecov-action@v5
6064

6165
- name: Run tests with lowest resolution
6266
if: matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest'
63-
run: uv run --group test --resolution lowest-direct pytest --nbmake -n auto
67+
run: just test-lowest
6468

6569
- name: Run tests with highest resolution
6670
if: matrix.python-version == '3.13' && matrix.os == 'ubuntu-latest'
67-
run: uv run --group test --resolution highest pytest --nbmake -n auto
71+
run: just test-highest

.github/workflows/publish-to-pypi.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ jobs:
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- uses: actions/checkout@v4
11+
- uses: actions/checkout@v5
1212
- name: Set up Python
13-
uses: actions/setup-python@v5
13+
uses: actions/setup-python@v6
1414
with:
1515
python-version: "3.x"
1616
- name: Install pypa/build
@@ -41,7 +41,7 @@ jobs:
4141

4242
steps:
4343
- name: Download all the dists
44-
uses: actions/download-artifact@v4
44+
uses: actions/download-artifact@v5
4545
with:
4646
name: python-package-distributions
4747
path: dist/
@@ -62,7 +62,7 @@ jobs:
6262

6363
steps:
6464
- name: Download all the dists
65-
uses: actions/download-artifact@v4
65+
uses: actions/download-artifact@v5
6666
with:
6767
name: python-package-distributions
6868
path: dist/

.github/workflows/update-plugin-list.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ jobs:
1919

2020
steps:
2121
- name: Checkout
22-
uses: actions/checkout@v4
22+
uses: actions/checkout@v5
2323
with:
2424
fetch-depth: 0
2525

2626
- name: Setup Python
27-
uses: actions/setup-python@v5
27+
uses: actions/setup-python@v6
2828
with:
2929
python-version: 3.12
3030

.pre-commit-config.yaml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
ci:
2-
skip: [type-checking]
3-
41
repos:
52
- repo: https://github.com/pre-commit/pre-commit-hooks
63
rev: v5.0.0
@@ -31,7 +28,7 @@ repos:
3128
rev: v0.12.4
3229
hooks:
3330
- id: ruff-format
34-
- id: ruff
31+
- id: ruff-check
3532
- repo: https://github.com/executablebooks/mdformat
3633
rev: 0.7.22
3734
hooks:
@@ -58,7 +55,7 @@ repos:
5855
- id: nbstripout
5956
exclude: (docs)
6057
- repo: https://github.com/crate-ci/typos
61-
rev: v1
58+
rev: v1.34.0
6259
hooks:
6360
- id: typos
6461
exclude: (\.ipynb)
@@ -67,10 +64,3 @@ repos:
6764
- id: check-hooks-apply
6865
- id: check-useless-excludes
6966
# - id: identity # Prints all files passed to pre-commits. Debugging.
70-
- repo: local
71-
hooks:
72-
- id: type-checking
73-
name: type-checking
74-
entry: uv run --group typing mypy
75-
language: system
76-
pass_filenames: false

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ chronological order. Releases follow [semantic versioning](https://semver.org/)
55
releases are available on [PyPI](https://pypi.org/project/pytask) and
66
[Anaconda.org](https://anaconda.org/conda-forge/pytask).
77

8+
## 0.5.6 - 2025-xx-xx
9+
10+
- {pull}`703` fixes {issue}`701` by allowing `--capture tee-sys` again.
11+
812
## 0.5.5 - 2025-07-25
913

1014
- {pull}`692` documents how to use pytask with workspaces.

docs/source/plugin_list.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ This list contains 7 plugins.
2727
:pypi:`pytask-latex` Compile LaTeX documents with pytask. Jun 01, 2025 4 - Beta pytask>=0.4.0
2828
:pypi:`pytask-parallel` Parallelize the execution of tasks with pytask. Mar 09, 2025 4 - Beta pytask>=0.5.2
2929
:pypi:`pytask-r` Run R scripts with pytask. Apr 20, 2024 4 - Beta pytask>=0.4.5
30-
:pypi:`pytask-stata` Execute do-files with Stata and pytask. May 19, 2024 4 - Beta pytask>=0.4
30+
:pypi:`pytask-stata` Execute do-files with Stata and pytask. Jul 26, 2025 4 - Beta pytask>=0.5.2
3131
:pypi:`pytask-vscode` Additional Logging for VS Code integration Nov 21, 2023 3 - Alpha pytask >=0.4.2
3232
========================== ==================================================================== ============== ========= ==============

justfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Install all dependencies
2+
install:
3+
uv sync --all-groups
4+
5+
# Run tests
6+
test *FLAGS:
7+
uv run --group test pytest {{FLAGS}}
8+
9+
# Run tests with coverage
10+
test-cov *FLAGS:
11+
uv run --group test pytest --nbmake --cov=src --cov=tests --cov-report=xml -n auto {{FLAGS}}
12+
13+
# Run tests with notebook validation
14+
test-nb:
15+
uv run --group test pytest --nbmake -n auto
16+
17+
# Run type checking
18+
typing:
19+
uv run --group typing --no-dev --isolated mypy
20+
21+
# Run type checking on notebooks
22+
typing-nb:
23+
uv run --group typing --no-dev --isolated nbqa mypy --ignore-missing-imports .
24+
25+
# Run linting
26+
lint:
27+
uvx --with pre-commit-uv pre-commit run -a
28+
29+
# Run all checks (format, lint, typing, test)
30+
check: lint typing test
31+
32+
# Build documentation
33+
docs:
34+
uv run --group docs sphinx-build docs/source docs/build
35+
36+
# Serve documentation with auto-reload
37+
docs-serve:
38+
uv run --group docs sphinx-autobuild docs/source docs/build
39+
40+
# Run tests with lowest dependency resolution (like CI)
41+
test-lowest:
42+
uv run --group test --resolution lowest-direct pytest --nbmake -n auto
43+
44+
# Run tests with highest dependency resolution (like CI)
45+
test-highest:
46+
uv run --group test --resolution highest pytest --nbmake -n auto

src/_pytask/click.py

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from typing import TYPE_CHECKING
1111
from typing import Any
1212
from typing import ClassVar
13-
from typing import TypeVar
1413

1514
import click
1615
from click import Choice
@@ -29,7 +28,6 @@
2928
from _pytask.console import create_panel_title
3029

3130
if TYPE_CHECKING:
32-
from collections.abc import Iterable
3331
from collections.abc import Sequence
3432

3533

@@ -38,50 +36,40 @@
3836

3937
if importlib.metadata.version("click") < "8.2":
4038
from click.parser import split_opt
39+
else:
40+
from click.parser import ( # type: ignore[attr-defined, no-redef, unused-ignore]
41+
_split_opt as split_opt,
42+
)
4143

42-
class EnumChoice(Choice):
43-
"""An enum-based choice type.
44-
45-
The implementation is copied from https://github.com/pallets/click/pull/2210 and
46-
related discussion can be found in https://github.com/pallets/click/issues/605.
4744

48-
In contrast to using :class:`click.Choice`, using this type ensures that the
49-
error message does not show the enum members.
45+
class EnumChoice(Choice): # type: ignore[type-arg, unused-ignore]
46+
"""An enum-based choice type.
5047
51-
In contrast to the proposed implementation in the PR, this implementation does
52-
not use the members than rather the values of the enum.
48+
The implementation is copied from https://github.com/pallets/click/pull/2210 and
49+
related discussion can be found in https://github.com/pallets/click/issues/605.
5350
54-
"""
51+
In contrast to using :class:`click.Choice`, using this type ensures that the
52+
error message does not show the enum members.
5553
56-
def __init__(self, enum_type: type[Enum], case_sensitive: bool = True) -> None:
57-
super().__init__(
58-
choices=[element.value for element in enum_type],
59-
case_sensitive=case_sensitive,
60-
)
61-
self.enum_type = enum_type
62-
63-
def convert(
64-
self, value: Any, param: Parameter | None, ctx: Context | None
65-
) -> Any:
66-
if isinstance(value, Enum):
67-
value = value.value
68-
value = super().convert(value=value, param=param, ctx=ctx)
69-
if value is None:
70-
return None
71-
return self.enum_type(value)
54+
In contrast to the proposed implementation in the PR, this implementation does
55+
not use the members than rather the values of the enum.
7256
73-
else:
74-
from click.parser import ( # type: ignore[attr-defined, no-redef]
75-
_split_opt as split_opt,
76-
)
57+
"""
7758

78-
ParamTypeValue = TypeVar("ParamTypeValue")
59+
def __init__(self, enum_type: type[Enum], case_sensitive: bool = True) -> None:
60+
super().__init__(
61+
choices=[element.value for element in enum_type],
62+
case_sensitive=case_sensitive,
63+
)
64+
self.enum_type = enum_type
7965

80-
class EnumChoice(Choice): # type: ignore[no-redef]
81-
def __init__(
82-
self, choices: Iterable[ParamTypeValue], case_sensitive: bool = False
83-
) -> None:
84-
super().__init__(choices=choices, case_sensitive=case_sensitive) # type: ignore[arg-type]
66+
def convert(self, value: Any, param: Parameter | None, ctx: Context | None) -> Any:
67+
if isinstance(value, Enum):
68+
value = value.value
69+
value = super().convert(value=value, param=param, ctx=ctx)
70+
if value is None:
71+
return None
72+
return self.enum_type(value)
8573

8674

8775
class _OptionHighlighter(RegexHighlighter):
@@ -340,7 +328,7 @@ def _format_help_text( # noqa: C901, PLR0912, PLR0915
340328
elif param.is_bool_flag and param.secondary_opts: # type: ignore[attr-defined]
341329
# For boolean flags that have distinct True/False opts,
342330
# use the opt without prefix instead of the value.
343-
default_string = split_opt(
331+
default_string = split_opt( # type: ignore[operator, unused-ignore]
344332
(param.opts if param.default else param.secondary_opts)[0]
345333
)[1]
346334
elif (

0 commit comments

Comments
 (0)