Skip to content

Commit 7c94263

Browse files
Bump ty from 0.0.24 to 0.0.30 (#850)
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tobias Raabe <raabe@posteo.de>
1 parent 378bb0d commit 7c94263

19 files changed

Lines changed: 178 additions & 79 deletions

pyproject.toml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,48 @@ unused-ignore-comment = "error"
171171
[[tool.ty.overrides]]
172172
include = [
173173
"src/_pytask/_version.py",
174-
"src/_pytask/click.py",
175174
"tests/test_dag_command.py",
176175
]
177176

178177
[tool.ty.overrides.rules]
179178
unused-ignore-comment = "ignore"
180179

180+
[[tool.ty.overrides]]
181+
include = ["src/_pytask/click.py"]
182+
183+
[tool.ty.overrides.rules]
184+
unresolved-attribute = "ignore"
185+
unused-ignore-comment = "ignore"
186+
187+
[[tool.ty.overrides]]
188+
include = ["src/_pytask/debugging.py"]
189+
190+
[tool.ty.overrides.rules]
191+
unsupported-base = "ignore"
192+
193+
[[tool.ty.overrides]]
194+
include = ["src/_pytask/hookspecs.py"]
195+
196+
[tool.ty.overrides.rules]
197+
empty-body = "ignore"
198+
199+
[[tool.ty.overrides]]
200+
include = ["src/_pytask/warnings_utils.py"]
201+
202+
[tool.ty.overrides.rules]
203+
unresolved-attribute = "ignore"
204+
205+
[[tool.ty.overrides]]
206+
include = ["tests/**/*.py", "tests/**/*.ipynb"]
207+
208+
[tool.ty.overrides.rules]
209+
call-non-callable = "ignore"
210+
invalid-argument-type = "ignore"
211+
invalid-return-type = "ignore"
212+
unresolved-attribute = "ignore"
213+
unresolved-reference = "ignore"
214+
unsupported-operator = "ignore"
215+
181216
[tool.ty.src]
182217
include = ["src", "tests"]
183218
exclude = ["src/_pytask/_hashlib.py"]

src/_pytask/capture.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def __exit__(
244244
@property
245245
def buffer(self) -> BinaryIO:
246246
# The str/bytes doesn't actually matter in this type, so OK to fake.
247-
return self # type: ignore[return-value]
247+
return cast("BinaryIO", self)
248248

249249

250250
# Capture classes.
@@ -553,7 +553,7 @@ def snap(self) -> bytes:
553553
res = self.tmpfile.buffer.read()
554554
self.tmpfile.seek(0)
555555
self.tmpfile.truncate()
556-
return res # type: ignore[return-value]
556+
return cast("bytes", res)
557557

558558
def writeorg(self, data: bytes) -> None:
559559
"""Write to original file descriptor."""
@@ -656,8 +656,10 @@ def pop_outerr_to_orig(self) -> tuple[AnyStr, AnyStr]:
656656
"""Pop current snapshot out/err capture and flush to orig streams."""
657657
out, err = self.readouterr()
658658
if out:
659+
assert self.out is not None
659660
self.out.writeorg(out) # type: ignore[union-attr]
660661
if err:
662+
assert self.err is not None
661663
self.err.writeorg(err) # type: ignore[union-attr]
662664
return out, err
663665

@@ -678,7 +680,8 @@ def resume_capturing(self) -> None:
678680
if self.err:
679681
self.err.resume()
680682
if self._in_suspended:
681-
self.in_.resume() # type: ignore[union-attr]
683+
assert self.in_ is not None
684+
self.in_.resume()
682685
self._in_suspended = False
683686

684687
def stop_capturing(self) -> None:
@@ -699,10 +702,9 @@ def is_started(self) -> bool:
699702
return self._state == "started"
700703

701704
def readouterr(self) -> CaptureResult[AnyStr]:
702-
out = self.out.snap() if self.out else ""
703-
err = self.err.snap() if self.err else ""
704-
# Will be fixed by pytest. This type error is real, need to fix.
705-
return CaptureResult(out, err) # type: ignore[arg-type]
705+
out = self.out.snap() if self.out else cast("AnyStr", "")
706+
err = self.err.snap() if self.err else cast("AnyStr", "")
707+
return CaptureResult(out, err)
706708

707709

708710
def _get_multicapture(method: CaptureMethod) -> MultiCapture[str]:

src/_pytask/collect.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ def _collect_not_collected_tasks(session: Session) -> None:
192192
for path in list(COLLECTED_TASKS):
193193
tasks = COLLECTED_TASKS.pop(path)
194194
for task in tasks:
195-
name = task.pytask_meta.name # type: ignore[attr-defined]
195+
name = task.pytask_meta.name
196+
assert name is not None
196197
node: PTask
197198
if path:
198199
node = Task(base_name=name, path=path, function=task)

src/_pytask/config_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ def set_defaults_from_config(
4343
# command-line options during parsing. Here, we add their defaults to the
4444
# configuration.
4545
command_option_names = [option.name for option in context.command.params]
46-
commands = context.parent.command.commands # type: ignore[union-attr]
46+
assert context.parent is not None
47+
assert isinstance(context.parent.command, click.Group)
48+
commands = context.parent.command.commands
4749
all_defaults_from_cli = {
4850
option.name: option.default
4951
for name, command in commands.items()

src/_pytask/console.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from pathlib import Path
99
from typing import TYPE_CHECKING
1010
from typing import Any
11+
from typing import Literal
1112
from typing import cast
1213

1314
from rich.console import Console
@@ -32,7 +33,6 @@
3233
from collections.abc import Callable
3334
from collections.abc import Iterable
3435
from collections.abc import Sequence
35-
from enum import Enum
3636

3737
from _pytask.node_protocols import PTask
3838
from _pytask.outcomes import CollectionOutcome
@@ -119,7 +119,10 @@ def render_to_string(
119119
except (AttributeError, IndexError, TypeError):
120120
theme = None
121121
render_console = Console(
122-
color_system=console.color_system, # type: ignore[invalid-argument-type]
122+
color_system=cast(
123+
"Literal['auto', 'standard', '256', 'truecolor', 'windows'] | None",
124+
console.color_system,
125+
),
123126
force_terminal=True,
124127
width=console.width,
125128
no_color=False,
@@ -282,7 +285,7 @@ def unify_styles(*styles: str | Style) -> Style:
282285

283286

284287
def create_summary_panel(
285-
counts: dict[Enum, int],
288+
counts: dict[CollectionOutcome | TaskOutcome, int],
286289
outcome_enum: type[CollectionOutcome | TaskOutcome],
287290
description_total: str,
288291
) -> Panel:
@@ -302,14 +305,14 @@ def create_summary_panel(
302305
grid.add_row(
303306
Padding(str(value), pad=_HORIZONTAL_PADDING),
304307
Padding(
305-
outcome.description, # type: ignore[attr-defined]
308+
outcome.description,
306309
pad=_HORIZONTAL_PADDING,
307310
),
308311
Padding(
309312
percentage,
310313
pad=_HORIZONTAL_PADDING,
311314
),
312-
style=outcome.style_textonly, # type: ignore[attr-defined]
315+
style=outcome.style_textonly,
313316
)
314317

315318
return Panel(

src/_pytask/data_catalog.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ def add(self, name: str, node: PNode | PProvisionalNode | Any = None) -> None:
125125
)
126126
else:
127127
self._entries[name] = self.default_node(name=name)
128-
self.path.joinpath(f"{filename}-node.pkl").write_bytes( # type: ignore[union-attr]
128+
assert self.path is not None
129+
self.path.joinpath(f"{filename}-node.pkl").write_bytes(
129130
pickle.dumps(self._entries[name])
130131
)
131132
elif isinstance(node, (PNode, PProvisionalNode)):

src/_pytask/debugging.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ def _parse_pdbcls(value: str | None) -> tuple[str, str] | None:
7676
"Must be like 'IPython.terminal.debugger:TerminalPdb'"
7777
)
7878
raise ValueError(msg)
79-
return tuple(split) # type: ignore[return-value]
79+
modname, classname = split
80+
return modname, classname
8081

8182

8283
def _pdbcls_callback(
@@ -383,7 +384,8 @@ def wrapper(*args: Any, **kwargs: Any) -> None:
383384
console.rule("Traceback", characters=">", style="default")
384385
console.print(Traceback(exc_info))
385386

386-
post_mortem(exc_info[2]) # type: ignore[arg-type]
387+
assert exc_info[2] is not None
388+
post_mortem(exc_info[2])
387389

388390
live_manager.resume()
389391
capman.resume()

src/_pytask/execute.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import time
88
from typing import TYPE_CHECKING
99
from typing import Any
10+
from typing import cast
1011

1112
from rich.text import Text
1213

@@ -220,7 +221,7 @@ def pytask_execute_task_setup(session: Session, task: PTask) -> None: # noqa: C
220221

221222
# Cast reason since get_node_change_info can return "unchanged"
222223
# but we only call this when has_changed is True
223-
reason_typed: ReasonType = reason # type: ignore[assignment]
224+
reason_typed = cast("ReasonType", reason)
224225
change_reasons.append(
225226
create_change_reason(
226227
node=node,

src/_pytask/hookspecs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def pytask_collect_task_setup(
180180
@hookspec(firstresult=True)
181181
def pytask_collect_task(
182182
session: Session, path: Path | None, name: str, obj: Any
183-
) -> PTask: # ty: ignore[empty-body]
183+
) -> PTask:
184184
"""Collect a single task."""
185185

186186

src/_pytask/mark/structures.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from _pytask.mark_utils import get_all_marks
99
from _pytask.models import CollectionMetadata
1010
from _pytask.typing import TaskFunction
11+
from _pytask.typing import attach_task_metadata
12+
from _pytask.typing import is_task_decorator_target
1113
from _pytask.typing import is_task_function
1214

1315
if TYPE_CHECKING:
@@ -174,9 +176,10 @@ def store_mark(obj: Callable[..., Any], mark: Mark) -> None:
174176
if isinstance(obj, TaskFunction):
175177
obj.pytask_meta.markers = [*get_unpacked_marks(obj), mark]
176178
else:
177-
obj.pytask_meta = CollectionMetadata( # type: ignore[attr-defined]
178-
markers=[mark]
179-
)
179+
if not is_task_decorator_target(obj):
180+
msg = "Marks can only be stored on user-defined callables."
181+
raise TypeError(msg)
182+
attach_task_metadata(obj, CollectionMetadata(markers=[mark]))
180183

181184

182185
_DEPRECATION_DECORATOR = """'@pytask.mark.{}' was removed in pytask v0.5.0. To upgrade \

0 commit comments

Comments
 (0)