Skip to content

Commit 36f7b23

Browse files
committed
Merge remote-tracking branch 'origin/main' into lockfile
2 parents 71cee05 + 4fbaba6 commit 36f7b23

File tree

7 files changed

+2108
-2707
lines changed

7 files changed

+2108
-2707
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Build a binary wheel and a source tarball
2323
run: python3 -m build
2424
- name: Store the distribution packages
25-
uses: actions/upload-artifact@v6
25+
uses: actions/upload-artifact@v7
2626
with:
2727
name: python-package-distributions
2828
path: dist/
@@ -41,7 +41,7 @@ jobs:
4141

4242
steps:
4343
- name: Download all the dists
44-
uses: actions/download-artifact@v7
44+
uses: actions/download-artifact@v8
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@v7
65+
uses: actions/download-artifact@v8
6666
with:
6767
name: python-package-distributions
6868
path: dist/

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ repos:
2525
- id: python-no-log-warn
2626
- id: text-unicode-replacement-char
2727
- repo: https://github.com/astral-sh/ruff-pre-commit
28-
rev: v0.15.1
28+
rev: v0.15.6
2929
hooks:
3030
- id: ruff-format
3131
- id: ruff-check
3232
- repo: https://github.com/astral-sh/uv-pre-commit
33-
rev: 0.10.3
33+
rev: 0.10.10
3434
hooks:
3535
- id: uv-lock
3636
- repo: https://github.com/executablebooks/mdformat
@@ -54,7 +54,7 @@ repos:
5454
]
5555
files: (docs/.)
5656
- repo: https://github.com/kynan/nbstripout
57-
rev: 0.9.0
57+
rev: 0.9.1
5858
hooks:
5959
- id: nbstripout
6060
exclude: (docs)

src/_pytask/cache.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,29 @@
1313
from typing import ParamSpec
1414
from typing import Protocol
1515
from typing import TypeVar
16+
from typing import cast
1617

1718
from _pytask._hashlib import hash_value
1819

20+
P = ParamSpec("P")
21+
R = TypeVar("R")
22+
1923
if TYPE_CHECKING:
2024
from collections.abc import Callable
21-
from typing import TypeAlias
2225

2326
from ty_extensions import Intersection
2427

25-
Memoized: TypeAlias = "Intersection[Callable[P, R], HasCache]"
26-
27-
P = ParamSpec("P")
28-
R = TypeVar("R")
29-
3028

3129
class HasCache(Protocol):
3230
"""Protocol for objects that have a cache attribute."""
3331

3432
cache: Cache
3533

3634

35+
if TYPE_CHECKING:
36+
Memoized = Intersection[Callable[P, R], HasCache]
37+
38+
3739
@dataclass
3840
class CacheInfo:
3941
hits: int = 0
@@ -68,9 +70,10 @@ def wrapped(*args: P.args, **kwargs: P.kwargs) -> R:
6870

6971
return value
7072

71-
wrapped.cache = self # ty: ignore[unresolved-attribute]
73+
wrapped_with_cache = cast("Memoized[P, R]", wrapped)
74+
wrapped_with_cache.cache = self
7275

73-
return wrapped
76+
return wrapped_with_cache
7477

7578
def add(self, key: str, value: Any) -> None:
7679
self._cache[key] = value

src/_pytask/collect.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ def pytask_collect_task(
352352
)
353353

354354
markers = get_all_marks(obj)
355+
attributes: dict[str, Any]
355356

356357
if isinstance(obj, TaskFunction):
357358
attributes = {
@@ -361,7 +362,11 @@ def pytask_collect_task(
361362
"is_generator": obj.pytask_meta.is_generator,
362363
}
363364
else:
364-
attributes = {"collection_id": None, "after": [], "is_generator": False}
365+
attributes = {
366+
"collection_id": None,
367+
"after": [],
368+
"is_generator": False,
369+
}
365370

366371
unwrapped = unwrap_task_function(obj)
367372
if isinstance(unwrapped, Function):

src/_pytask/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def pytask_configure(pm: PluginManager, raw_config: dict[str, Any]) -> dict[str,
6666
"""Configure pytask."""
6767
# Add all values by default so that many plugins do not need to copy over values.
6868
config = {"pm": pm, "markers": {}} | raw_config
69-
config["markers"] = parse_markers(config["markers"]) # type: ignore[arg-type]
69+
config["markers"] = parse_markers(config["markers"])
7070

7171
pm.hook.pytask_parse_config(config=config)
7272
pm.hook.pytask_post_parse(config=config)

tests/test_collect_command.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import textwrap
66
from dataclasses import dataclass
77
from pathlib import Path
8+
from typing import TYPE_CHECKING
89

910
import pytest
1011

@@ -16,6 +17,9 @@
1617
from pytask import cli
1718
from tests.conftest import enter_directory
1819

20+
if TYPE_CHECKING:
21+
from _pytask.node_protocols import PTaskWithPath
22+
1923

2024
def test_collect_task(runner, tmp_path):
2125
source = """
@@ -315,7 +319,7 @@ def function(depends_on, produces): ...
315319

316320

317321
def test_print_collected_tasks_without_nodes(capsys):
318-
dictionary = {
322+
dictionary: dict[Path, list[PTaskWithPath]] = {
319323
Path("task_path.py"): [
320324
Task(
321325
base_name="function",
@@ -337,7 +341,7 @@ def test_print_collected_tasks_without_nodes(capsys):
337341

338342

339343
def test_print_collected_tasks_with_nodes(capsys):
340-
dictionary = {
344+
dictionary: dict[Path, list[PTaskWithPath]] = {
341345
Path("task_path.py"): [
342346
Task(
343347
base_name="function",
@@ -361,7 +365,7 @@ def test_print_collected_tasks_with_nodes(capsys):
361365

362366
@pytest.mark.parametrize(("show_nodes", "expected_add"), [(False, "src"), (True, "..")])
363367
def test_find_common_ancestor_of_all_nodes(show_nodes, expected_add):
364-
tasks = [
368+
tasks: list[PTaskWithPath] = [
365369
Task(
366370
base_name="function",
367371
path=Path.cwd() / "src" / "task_path.py",

0 commit comments

Comments
 (0)