Skip to content

Commit 172ba0e

Browse files
authored
Publish more functions. (#237)
1 parent 06815dc commit 172ba0e

File tree

6 files changed

+65
-25
lines changed

6 files changed

+65
-25
lines changed

codecov.yml

-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,3 @@ coverage:
2424

2525
ignore:
2626
- ".tox/**/*"
27-
- "setup.py"

docs/source/changes.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and
2424
{mod}`_pytask.mark_utils`. (Closes {issue}`220`.)
2525
- {pull}`236` refactors {mod}`_pytask.collect` and places shared functions in
2626
{mod}`_pytask.collect_utils`.
27+
- {pull}`237` publish more functions.
2728
- {pull}`238` allows any order of decorators with a `@pytask.mark.task` decorator.
2829
- {pull}`241` allows to parametrize over single dicts.
2930
- {pull}`242` removes tasks from global {obj}`_pytask.task_utils.COLLECTED_TASKS` to

src/_pytask/session.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,26 @@
3030
class Session:
3131
"""The session of pytask."""
3232

33-
config = attr.ib(factory=dict, type=Optional[Dict[str, Any]])
34-
"""Optional[Dict[str, Any]]: Configuration of the session."""
33+
config = attr.ib(factory=dict, type=Dict[str, Any])
34+
"""Dict[str, Any]: Configuration of the session."""
3535
hook = attr.ib(default=None, type=Optional[_HookRelay])
3636
"""Optional[pluggy.hooks._HookRelay]: Holds all hooks collected by pytask."""
3737
collection_reports = attr.ib(factory=list, type=List["CollectionReport"])
38-
"""Optional[List[CollectionReport]]: Reports for collected items.
38+
"""List[CollectionReport]: Reports for collected items.
3939
4040
The reports capture errors which happened while collecting tasks.
4141
4242
"""
43-
tasks = attr.ib(factory=list, type=Optional[List["Task"]])
44-
"""Optional[List[Task]]: List of collected tasks."""
43+
tasks = attr.ib(factory=list, type=List["Task"])
44+
"""List[Task]: List of collected tasks."""
4545
dag = attr.ib(default=None, type=Optional[nx.DiGraph])
4646
resolving_dependencies_report = attr.ib(
4747
default=None, type=Optional["ResolvingDependenciesReport"]
4848
)
4949
"""Optional[ResolvingDependenciesReport]: Reports for resolving dependencies
5050
failed."""
51-
execution_reports = attr.ib(factory=list, type=Optional[List["ExecutionReport"]])
52-
"""Optional[List[ExecutionReport]]: Reports for executed tasks."""
51+
execution_reports = attr.ib(factory=list, type=List["ExecutionReport"])
52+
"""List[ExecutionReport]: Reports for executed tasks."""
5353
exit_code = attr.ib(default=ExitCode.OK, type=ExitCode)
5454

5555
collection_start = attr.ib(default=None, type=Optional[float])

src/_pytask/traceback.py

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
from rich.traceback import Traceback
1414

1515

16+
__all__ = [
17+
"format_exception_without_traceback",
18+
"remove_internal_traceback_frames_from_exc_info",
19+
"remove_traceback_from_exc_info",
20+
"render_exc_info",
21+
]
22+
23+
1624
_PLUGGY_DIRECTORY = Path(pluggy.__file__).parent
1725
_PYTASK_DIRECTORY = Path(_pytask.__file__).parent
1826

src/pytask/__init__.py

+32-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
from _pytask.compat import import_optional_dependency
1111
from _pytask.config import hookimpl
1212
from _pytask.console import console
13+
from _pytask.database import db
14+
from _pytask.exceptions import CollectionError
15+
from _pytask.exceptions import ConfigurationError
16+
from _pytask.exceptions import ExecutionError
17+
from _pytask.exceptions import NodeNotCollectedError
18+
from _pytask.exceptions import NodeNotFoundError
19+
from _pytask.exceptions import PytaskError
20+
from _pytask.exceptions import ResolvingDependenciesError
1321
from _pytask.graph import build_dag
1422
from _pytask.mark import Mark
1523
from _pytask.mark import MARK_GEN as mark # noqa: N811
@@ -32,7 +40,15 @@
3240
from _pytask.outcomes import SkippedAncestorFailed
3341
from _pytask.outcomes import SkippedUnchanged
3442
from _pytask.outcomes import TaskOutcome
43+
from _pytask.report import CollectionReport
44+
from _pytask.report import ExecutionReport
45+
from _pytask.report import ResolvingDependenciesReport
3546
from _pytask.session import Session
47+
from _pytask.traceback import format_exception_without_traceback
48+
from _pytask.traceback import remove_internal_traceback_frames_from_exc_info
49+
from _pytask.traceback import remove_traceback_from_exc_info
50+
from _pytask.traceback import render_exc_info
51+
3652

3753
# This import must come last, otherwise a circular import occurs.
3854
from _pytask.cli import cli # noreorder
@@ -45,7 +61,9 @@
4561
"cli",
4662
"console",
4763
"count_outcomes",
64+
"db",
4865
"depends_on",
66+
"format_exception_without_traceback",
4967
"get_all_marks",
5068
"get_marks",
5169
"has_mark",
@@ -55,22 +73,34 @@
5573
"mark",
5674
"parse_nodes",
5775
"produces",
76+
"remove_internal_traceback_frames_from_exc_info",
5877
"remove_marks",
78+
"remove_traceback_from_exc_info",
79+
"render_exc_info",
5980
"set_marks",
81+
"CollectionError",
6082
"CollectionOutcome",
83+
"CollectionReport",
84+
"ConfigurationError",
85+
"ExecutionReport",
86+
"ExecutionError",
6187
"Exit",
6288
"ExitCode",
6389
"FilePathNode",
6490
"Mark",
6591
"MarkDecorator",
6692
"MarkGenerator",
6793
"MetaNode",
68-
"Task",
94+
"NodeNotCollectedError",
95+
"NodeNotFoundError",
6996
"Persisted",
70-
"Task",
97+
"PytaskError",
98+
"ResolvingDependenciesError",
99+
"ResolvingDependenciesReport",
71100
"Session",
72101
"Skipped",
73102
"SkippedAncestorFailed",
74103
"SkippedUnchanged",
104+
"Task",
75105
"TaskOutcome",
76106
]

tests/test_shared.py

+17-15
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,26 @@
1010

1111
@pytest.mark.unit
1212
@pytest.mark.parametrize(
13-
"value, expected",
13+
"value, expectation, expected",
1414
[
15-
(True, True),
16-
("True", True),
17-
("true", True),
18-
("1", True),
19-
(False, False),
20-
("False", False),
21-
("false", False),
22-
("0", False),
23-
(None, None),
24-
("None", None),
25-
("none", None),
15+
(True, does_not_raise(), True),
16+
("True", does_not_raise(), True),
17+
("true", does_not_raise(), True),
18+
("1", does_not_raise(), True),
19+
(False, does_not_raise(), False),
20+
("False", does_not_raise(), False),
21+
("false", does_not_raise(), False),
22+
("0", does_not_raise(), False),
23+
(None, does_not_raise(), None),
24+
("None", does_not_raise(), None),
25+
("none", does_not_raise(), None),
26+
("asklds", pytest.raises(ValueError, match="Input"), None),
2627
],
2728
)
28-
def test_convert_truthy_or_falsy_to_bool(value, expected):
29-
result = convert_truthy_or_falsy_to_bool(value)
30-
assert result == expected
29+
def test_convert_truthy_or_falsy_to_bool(value, expectation, expected):
30+
with expectation:
31+
result = convert_truthy_or_falsy_to_bool(value)
32+
assert result == expected
3133

3234

3335
@pytest.mark.unit

0 commit comments

Comments
 (0)