From 840e639bba41c053badb235b9cdafa79b09e8e2d Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Tue, 18 Jan 2022 21:20:43 +0100 Subject: [PATCH 01/12] Add py.typed to package. --- MANIFEST.in | 2 ++ src/_pytask/py.typed | 0 src/pytask/py.typed | 0 3 files changed, 2 insertions(+) create mode 100644 src/_pytask/py.typed create mode 100644 src/pytask/py.typed diff --git a/MANIFEST.in b/MANIFEST.in index 97dc9c8c..496ccc9a 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,8 @@ include CITATION include LICENSE +recursive-include src py.typed + exclude *.yaml exclude *.yml exclude tox.ini diff --git a/src/_pytask/py.typed b/src/_pytask/py.typed new file mode 100644 index 00000000..e69de29b diff --git a/src/pytask/py.typed b/src/pytask/py.typed new file mode 100644 index 00000000..e69de29b From 26a383af1cb73cd1b2b25de81199ee6014297df0 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Tue, 18 Jan 2022 23:23:05 +0100 Subject: [PATCH 02/12] Add objects to fully type pytask_parallel. --- src/pytask/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/pytask/__init__.py b/src/pytask/__init__.py index e6d25448..48a7fbd3 100644 --- a/src/pytask/__init__.py +++ b/src/pytask/__init__.py @@ -5,6 +5,17 @@ from _pytask.config import hookimpl from _pytask.graph import build_dag from _pytask.mark import MARK_GEN as mark # noqa: N811 +from _pytask.nodes import MetaTask +from _pytask.session import Session -__all__ = ["__version__", "build_dag", "cli", "hookimpl", "main", "mark"] +__all__ = [ + "__version__", + "build_dag", + "cli", + "hookimpl", + "main", + "mark", + "MetaTask", + "Session", +] From 51cccf23eafe32b81108bfafbf213deb9c1b5f3d Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Wed, 19 Jan 2022 18:32:52 +0100 Subject: [PATCH 03/12] TEMP COMMIT. --- src/_pytask/hookspecs.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/_pytask/hookspecs.py b/src/_pytask/hookspecs.py index 6982ef47..8b76a751 100644 --- a/src/_pytask/hookspecs.py +++ b/src/_pytask/hookspecs.py @@ -12,7 +12,7 @@ from typing import Optional from typing import Tuple from typing import TYPE_CHECKING -from typing import Union +from typing import Union, cast, TypeVar, Protocol import click import networkx as nx @@ -30,7 +30,13 @@ from _pytask.reports import ResolveDependencyReport -hookspec = pluggy.HookspecMarker("pytask") + +class C(Protocol): + def __call__(self, firstresult:bool) -> Any: ... + + +F = TypeVar("F", bound=Callable[..., Any]) +hookspec = cast(Callable[[F], F], pluggy.HookspecMarker("pytask")) @hookspec From 19422372956adcb2267d0a9919bb70b2bcbdc304 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sun, 13 Feb 2022 23:16:28 +0100 Subject: [PATCH 04/12] publish more. --- .pre-commit-config.yaml | 1 - src/pytask/__init__.py | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 115dd1fc..3dfd7773 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -108,7 +108,6 @@ repos: types-setuptools ] pass_filenames: false - language_version: "3.9" - repo: meta hooks: - id: check-hooks-apply diff --git a/src/pytask/__init__.py b/src/pytask/__init__.py index 18214e2b..43eab012 100644 --- a/src/pytask/__init__.py +++ b/src/pytask/__init__.py @@ -1,6 +1,9 @@ """This module contains the main namespace for pytask.""" from __future__ import annotations +from _pytaks.mark_utils import get_specific_markers_from_task +from _pytaks.mark_utils import has_marker +from _pytaks.mark_utils import remove_markers_from_func from _pytask import __version__ from _pytask.build import main from _pytask.cli import cli @@ -21,9 +24,12 @@ "__version__", "build_dag", "cli", + "get_specific_markers_from_task", + "has_marker", "hookimpl", "main", "mark", + "remove_markers_from_func", "FilePathNode", "Mark", "MarkDecorator", From 9b22a335dcd0084b460cb80149f22c3d7901a931 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Mon, 14 Feb 2022 23:20:27 +0100 Subject: [PATCH 05/12] Publish compat module. --- src/_pytask/compat.py | 3 +++ src/pytask/__init__.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/_pytask/compat.py b/src/_pytask/compat.py index 733f1294..bfeafa3d 100644 --- a/src/_pytask/compat.py +++ b/src/_pytask/compat.py @@ -10,6 +10,9 @@ from packaging.version import parse as parse_version +__all__ = ["check_for_optional_program", "import_optional_dependency"] + + _MINIMUM_VERSIONS: dict[str, str] = {} """Dict[str, str]: A mapping from packages to their minimum versions.""" diff --git a/src/pytask/__init__.py b/src/pytask/__init__.py index 43eab012..99fc82b1 100644 --- a/src/pytask/__init__.py +++ b/src/pytask/__init__.py @@ -7,6 +7,8 @@ from _pytask import __version__ from _pytask.build import main from _pytask.cli import cli +from _pytask.compat import check_for_optional_program +from _pytask.compat import import_optional_dependency from _pytask.config import hookimpl from _pytask.graph import build_dag from _pytask.mark import Mark @@ -23,10 +25,12 @@ __all__ = [ "__version__", "build_dag", + "check_for_optional_program", "cli", "get_specific_markers_from_task", "has_marker", "hookimpl", + "import_optional_dependency", "main", "mark", "remove_markers_from_func", From 3e0e9f44ea358ca79acefcb89651ad6a241b53b6 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sun, 20 Feb 2022 18:47:43 +0100 Subject: [PATCH 06/12] Remove typing of hooksspecs. --- src/_pytask/hookspecs.py | 16 +--------------- src/pytask/__init__.py | 6 +++--- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/_pytask/hookspecs.py b/src/_pytask/hookspecs.py index df729e73..1df1fe12 100644 --- a/src/_pytask/hookspecs.py +++ b/src/_pytask/hookspecs.py @@ -6,23 +6,15 @@ """ from __future__ import annotations -import sys from pathlib import Path from typing import Any from typing import Callable -from typing import cast from typing import TYPE_CHECKING -from typing import TypeVar import click import networkx as nx import pluggy -if sys.version_info < (3, 8): - from typing_extensions import Protocol -else: - from typing import Protocol - if TYPE_CHECKING: from _pytask.session import Session @@ -35,13 +27,7 @@ from _pytask.reports import ResolveDependencyReport -class C(Protocol): - def __call__(self, firstresult: bool) -> Any: - ... - - -F = TypeVar("F", bound=Callable[..., Any]) -hookspec = cast(Callable[[F], F], pluggy.HookspecMarker("pytask")) +hookspec = pluggy.HookspecMarker("pytask") @hookspec diff --git a/src/pytask/__init__.py b/src/pytask/__init__.py index 99fc82b1..136f88b5 100644 --- a/src/pytask/__init__.py +++ b/src/pytask/__init__.py @@ -1,9 +1,6 @@ """This module contains the main namespace for pytask.""" from __future__ import annotations -from _pytaks.mark_utils import get_specific_markers_from_task -from _pytaks.mark_utils import has_marker -from _pytaks.mark_utils import remove_markers_from_func from _pytask import __version__ from _pytask.build import main from _pytask.cli import cli @@ -15,6 +12,9 @@ from _pytask.mark import MARK_GEN as mark # noqa: N811 from _pytask.mark import MarkDecorator from _pytask.mark import MarkGenerator +from _pytask.mark_utils import get_specific_markers_from_task +from _pytask.mark_utils import has_marker +from _pytask.mark_utils import remove_markers_from_func from _pytask.nodes import FilePathNode from _pytask.nodes import MetaNode from _pytask.nodes import MetaTask From d317f8920477fabfa1ce0720c639eae1c1e2f4d2 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sun, 20 Feb 2022 21:53:02 +0100 Subject: [PATCH 07/12] Publish more objects and use them in tests. --- .pre-commit-config.yaml | 2 +- src/_pytask/click.py | 8 ++++++++ src/_pytask/outcomes.py | 18 ++++++++++++++++++ src/pytask/__init__.py | 22 ++++++++++++++++++++++ tests/test_build.py | 2 +- tests/test_capture.py | 2 +- tests/test_clean.py | 2 +- tests/test_cli.py | 2 +- tests/test_collect.py | 13 +++++++------ tests/test_collect_command.py | 4 ++-- tests/test_compat.py | 4 ++-- tests/test_console.py | 8 ++++---- tests/test_dag.py | 4 ++-- tests/test_database.py | 2 +- tests/test_debugging.py | 2 +- tests/test_execute.py | 4 ++-- tests/test_graph.py | 2 +- tests/test_live.py | 6 +++--- tests/test_mark.py | 4 ++-- tests/test_mark_utils.py | 10 +++++----- tests/test_nodes.py | 6 +++--- tests/test_outcomes.py | 6 +++--- tests/test_parametrize.py | 4 ++-- tests/test_persist.py | 6 +++--- tests/test_profile.py | 2 +- tests/test_resolve_dependencies.py | 6 +++--- tests/test_skipping.py | 12 ++++++------ tests/test_task.py | 2 +- tests/test_traceback.py | 2 +- 29 files changed, 108 insertions(+), 59 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 05197457..1c2b5db9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -80,7 +80,7 @@ repos: rev: 1.5.0 hooks: - id: interrogate - args: [-v, --fail-under=40, src, tests] + args: [-v, --fail-under=40, src] - repo: https://github.com/codespell-project/codespell rev: v2.1.0 hooks: diff --git a/src/_pytask/click.py b/src/_pytask/click.py index 56828bbc..b90ee215 100644 --- a/src/_pytask/click.py +++ b/src/_pytask/click.py @@ -1,3 +1,4 @@ +"""This module contains code related to click.""" from __future__ import annotations from typing import Any @@ -18,11 +19,16 @@ class OptionHighlighter(RegexHighlighter): + """A highlighter for help texts.""" + highlights = [_SWITCH_REGEX, _OPTION_REGEX, _METAVAR_REGEX] class ColoredGroup(DefaultGroup): + """A subclass which colors groups with default commands.""" + def format_help(self: DefaultGroup, ctx: Any, formatter: Any) -> None: # noqa: U100 + """Format the help text.""" highlighter = OptionHighlighter() console.print( @@ -71,6 +77,7 @@ class ColoredCommand(click.Command): def format_help( self: click.Command, ctx: Any, formatter: Any # noqa: U100 ) -> None: + """Format the help text.""" console.print( f"[b]pytask[/b] [dim]v{version}[/]\n", justify="center", highlight=False ) @@ -91,6 +98,7 @@ def format_help( def print_options(group_or_command: click.Command | DefaultGroup, ctx: Any) -> None: + """Print options formatted with a table in a panel.""" highlighter = OptionHighlighter() options_table = Table(highlight=True, box=None, show_header=False) diff --git a/src/_pytask/outcomes.py b/src/_pytask/outcomes.py index 839cea11..521e51c0 100644 --- a/src/_pytask/outcomes.py +++ b/src/_pytask/outcomes.py @@ -13,6 +13,20 @@ from _pytask.report import ExecutionReport +__all__ = [ + "count_outcomes", + "CollectionOutcome", + "Exit", + "ExitCode", + "Persisted", + "PytaskOutcome", + "Skipped", + "SkippedUnchanged", + "SkippedAncestorFailed", + "TaskOutcome", +] + + class CollectionOutcome(Enum): """Outcomes of collected files or tasks. @@ -30,6 +44,7 @@ class CollectionOutcome(Enum): @property def symbol(self) -> str: + """The symbol of an outcome.""" symbols = { CollectionOutcome.SUCCESS: ".", CollectionOutcome.FAIL: "F", @@ -39,6 +54,7 @@ def symbol(self) -> str: @property def description(self) -> str: + """A description of an outcome used in the summary panel.""" descriptions = { CollectionOutcome.SUCCESS: "Succeeded", CollectionOutcome.FAIL: "Failed", @@ -48,6 +64,7 @@ def description(self) -> str: @property def style(self) -> str: + """Return the style of an outcome.""" styles = { CollectionOutcome.SUCCESS: "success", CollectionOutcome.FAIL: "failed", @@ -57,6 +74,7 @@ def style(self) -> str: @property def style_textonly(self) -> str: + """Return the style of an outcome when only the text is colored.""" styles_textonly = { CollectionOutcome.SUCCESS: "success.textonly", CollectionOutcome.FAIL: "failed.textonly", diff --git a/src/pytask/__init__.py b/src/pytask/__init__.py index 136f88b5..c71ead8a 100644 --- a/src/pytask/__init__.py +++ b/src/pytask/__init__.py @@ -7,11 +7,13 @@ from _pytask.compat import check_for_optional_program from _pytask.compat import import_optional_dependency from _pytask.config import hookimpl +from _pytask.console import console from _pytask.graph import build_dag from _pytask.mark import Mark from _pytask.mark import MARK_GEN as mark # noqa: N811 from _pytask.mark import MarkDecorator from _pytask.mark import MarkGenerator +from _pytask.mark_utils import get_marks_from_obj from _pytask.mark_utils import get_specific_markers_from_task from _pytask.mark_utils import has_marker from _pytask.mark_utils import remove_markers_from_func @@ -19,6 +21,15 @@ from _pytask.nodes import MetaNode from _pytask.nodes import MetaTask from _pytask.nodes import PythonFunctionTask +from _pytask.outcomes import CollectionOutcome +from _pytask.outcomes import count_outcomes +from _pytask.outcomes import Exit +from _pytask.outcomes import ExitCode +from _pytask.outcomes import Persisted +from _pytask.outcomes import Skipped +from _pytask.outcomes import SkippedAncestorFailed +from _pytask.outcomes import SkippedUnchanged +from _pytask.outcomes import TaskOutcome from _pytask.session import Session @@ -27,6 +38,9 @@ "build_dag", "check_for_optional_program", "cli", + "console", + "count_outcomes", + "get_marks_from_obj", "get_specific_markers_from_task", "has_marker", "hookimpl", @@ -34,12 +48,20 @@ "main", "mark", "remove_markers_from_func", + "CollectionOutcome", + "Exit", + "ExitCode", "FilePathNode", "Mark", "MarkDecorator", "MarkGenerator", "MetaNode", "MetaTask", + "Persisted", "PythonFunctionTask", "Session", + "Skipped", + "SkippedAncestorFailed", + "SkippedUnchanged", + "TaskOutcome", ] diff --git a/tests/test_build.py b/tests/test_build.py index 0ebc058a..bb1e753a 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -3,8 +3,8 @@ import textwrap import pytest -from _pytask.outcomes import ExitCode from pytask import cli +from pytask import ExitCode @pytest.mark.end_to_end diff --git a/tests/test_capture.py b/tests/test_capture.py index 05c7f8f2..1e4faf85 100644 --- a/tests/test_capture.py +++ b/tests/test_capture.py @@ -19,8 +19,8 @@ from _pytask.capture import CaptureManager from _pytask.capture import CaptureResult from _pytask.capture import MultiCapture -from _pytask.outcomes import ExitCode from pytask import cli +from pytask import ExitCode @pytest.mark.unit diff --git a/tests/test_clean.py b/tests/test_clean.py index fecbf4eb..c94bcbe1 100644 --- a/tests/test_clean.py +++ b/tests/test_clean.py @@ -3,8 +3,8 @@ import textwrap import pytest -from _pytask.outcomes import ExitCode from pytask import cli +from pytask import ExitCode @pytest.fixture() diff --git a/tests/test_cli.py b/tests/test_cli.py index c43730b0..9fbbaaa6 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -3,9 +3,9 @@ import subprocess import pytest -from _pytask.outcomes import ExitCode from pytask import __version__ from pytask import cli +from pytask import ExitCode @pytest.mark.end_to_end diff --git a/tests/test_collect.py b/tests/test_collect.py index f1c724bc..8c8c749e 100644 --- a/tests/test_collect.py +++ b/tests/test_collect.py @@ -2,6 +2,7 @@ import sys import textwrap +import warnings from contextlib import ExitStack as does_not_raise # noqa: N813 from pathlib import Path @@ -10,12 +11,12 @@ from _pytask.collect import pytask_collect_node from _pytask.exceptions import NodeNotCollectedError from _pytask.nodes import create_task_name -from _pytask.nodes import PythonFunctionTask -from _pytask.outcomes import CollectionOutcome -from _pytask.outcomes import ExitCode -from _pytask.session import Session from pytask import cli +from pytask import CollectionOutcome +from pytask import ExitCode from pytask import main +from pytask import PythonFunctionTask +from pytask import Session @pytest.mark.end_to_end @@ -176,11 +177,11 @@ def test_pytask_collect_node_does_not_raise_error_if_path_is_not_normalized( if is_absolute: collected_node = tmp_path / collected_node - with pytest.warns(None) as record: + with warnings.catch_warnings() as record: result = pytask_collect_node(session, task_path, collected_node) + assert not record assert str(result.path) == str(real_node) - assert not record @pytest.mark.unit diff --git a/tests/test_collect_command.py b/tests/test_collect_command.py index 8c6b555f..bff56476 100644 --- a/tests/test_collect_command.py +++ b/tests/test_collect_command.py @@ -7,9 +7,9 @@ import pytest from _pytask.collect_command import _find_common_ancestor_of_all_nodes from _pytask.collect_command import _print_collected_tasks -from _pytask.nodes import MetaNode -from _pytask.nodes import MetaTask from pytask import cli +from pytask import MetaNode +from pytask import MetaTask @pytest.mark.end_to_end diff --git a/tests/test_compat.py b/tests/test_compat.py index f5d6fa47..b6cadd59 100644 --- a/tests/test_compat.py +++ b/tests/test_compat.py @@ -6,8 +6,8 @@ import pytest from _pytask.compat import _MINIMUM_VERSIONS -from _pytask.compat import check_for_optional_program -from _pytask.compat import import_optional_dependency +from pytask import check_for_optional_program +from pytask import import_optional_dependency @pytest.mark.unit diff --git a/tests/test_console.py b/tests/test_console.py index 96fda556..5bb6956e 100644 --- a/tests/test_console.py +++ b/tests/test_console.py @@ -6,16 +6,16 @@ import pytest from _pytask.console import _get_file from _pytask.console import _get_source_lines -from _pytask.console import console from _pytask.console import create_summary_panel from _pytask.console import create_url_style_for_path from _pytask.console import create_url_style_for_task from _pytask.console import format_task_id from _pytask.console import render_to_string from _pytask.nodes import create_task_name -from _pytask.nodes import PythonFunctionTask -from _pytask.outcomes import CollectionOutcome -from _pytask.outcomes import TaskOutcome +from pytask import CollectionOutcome +from pytask import console +from pytask import PythonFunctionTask +from pytask import TaskOutcome from rich.console import Console from rich.style import Style from rich.text import Span diff --git a/tests/test_dag.py b/tests/test_dag.py index e42df47c..774a6d17 100644 --- a/tests/test_dag.py +++ b/tests/test_dag.py @@ -10,8 +10,8 @@ from _pytask.dag import node_and_neighbors from _pytask.dag import task_and_descending_tasks from _pytask.dag import TopologicalSorter -from _pytask.mark import Mark -from _pytask.nodes import MetaTask +from pytask import Mark +from pytask import MetaTask @attr.s diff --git a/tests/test_database.py b/tests/test_database.py index 9a12176d..34cf9fd4 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -6,9 +6,9 @@ import pytest from _pytask.database import create_database from _pytask.database import State -from _pytask.outcomes import ExitCode from pony import orm from pytask import cli +from pytask import ExitCode @pytest.mark.end_to_end diff --git a/tests/test_debugging.py b/tests/test_debugging.py index 69ece020..e24da1d8 100644 --- a/tests/test_debugging.py +++ b/tests/test_debugging.py @@ -8,8 +8,8 @@ import pytest from _pytask.debugging import _pdbcls_callback -from _pytask.outcomes import ExitCode from pytask import cli +from pytask import ExitCode try: import pexpect diff --git a/tests/test_execute.py b/tests/test_execute.py index ed025d39..3798020a 100644 --- a/tests/test_execute.py +++ b/tests/test_execute.py @@ -6,10 +6,10 @@ import pytest from _pytask.exceptions import NodeNotFoundError -from _pytask.outcomes import ExitCode -from _pytask.outcomes import TaskOutcome from pytask import cli +from pytask import ExitCode from pytask import main +from pytask import TaskOutcome @pytest.mark.end_to_end diff --git a/tests/test_graph.py b/tests/test_graph.py index 908aec79..b610a20b 100644 --- a/tests/test_graph.py +++ b/tests/test_graph.py @@ -4,8 +4,8 @@ import textwrap import pytest -from _pytask.outcomes import ExitCode from pytask import cli +from pytask import ExitCode try: import pydot # noqa: F401 diff --git a/tests/test_live.py b/tests/test_live.py index 6679bb31..2e6ac028 100644 --- a/tests/test_live.py +++ b/tests/test_live.py @@ -7,11 +7,11 @@ from _pytask.live import _parse_n_entries_in_table from _pytask.live import LiveExecution from _pytask.live import LiveManager -from _pytask.nodes import PythonFunctionTask -from _pytask.outcomes import ExitCode -from _pytask.outcomes import TaskOutcome from _pytask.report import ExecutionReport from pytask import cli +from pytask import ExitCode +from pytask import PythonFunctionTask +from pytask import TaskOutcome @pytest.mark.unit diff --git a/tests/test_mark.py b/tests/test_mark.py index 706b6361..b02690b4 100644 --- a/tests/test_mark.py +++ b/tests/test_mark.py @@ -5,10 +5,10 @@ import pytask import pytest -from _pytask.mark import MarkGenerator -from _pytask.outcomes import ExitCode from pytask import cli +from pytask import ExitCode from pytask import main +from pytask import MarkGenerator @pytest.mark.unit diff --git a/tests/test_mark_utils.py b/tests/test_mark_utils.py index c78ef15f..ae8145ad 100644 --- a/tests/test_mark_utils.py +++ b/tests/test_mark_utils.py @@ -3,11 +3,11 @@ import attr import pytask import pytest -from _pytask.mark_utils import get_marks_from_obj -from _pytask.mark_utils import get_specific_markers_from_task -from _pytask.mark_utils import has_marker -from _pytask.mark_utils import remove_markers_from_func -from _pytask.nodes import MetaTask +from pytask import get_marks_from_obj +from pytask import get_specific_markers_from_task +from pytask import has_marker +from pytask import MetaTask +from pytask import remove_markers_from_func @attr.s diff --git a/tests/test_nodes.py b/tests/test_nodes.py index ac603697..16956e90 100644 --- a/tests/test_nodes.py +++ b/tests/test_nodes.py @@ -13,11 +13,11 @@ from _pytask.nodes import _extract_nodes_from_function_markers from _pytask.nodes import create_task_name from _pytask.nodes import depends_on -from _pytask.nodes import FilePathNode -from _pytask.nodes import MetaNode -from _pytask.nodes import MetaTask from _pytask.nodes import produces from _pytask.shared import reduce_node_name +from pytask import FilePathNode +from pytask import MetaNode +from pytask import MetaTask @pytest.mark.unit diff --git a/tests/test_outcomes.py b/tests/test_outcomes.py index 1fc4c82e..e756112f 100644 --- a/tests/test_outcomes.py +++ b/tests/test_outcomes.py @@ -1,11 +1,11 @@ from __future__ import annotations import pytest -from _pytask.outcomes import CollectionOutcome -from _pytask.outcomes import count_outcomes -from _pytask.outcomes import TaskOutcome from _pytask.report import CollectionReport from _pytask.report import ExecutionReport +from pytask import CollectionOutcome +from pytask import count_outcomes +from pytask import TaskOutcome @pytest.mark.unit diff --git a/tests/test_parametrize.py b/tests/test_parametrize.py index de2b4257..d212cb79 100644 --- a/tests/test_parametrize.py +++ b/tests/test_parametrize.py @@ -7,15 +7,15 @@ import _pytask.parametrize import pytask import pytest -from _pytask.mark import Mark -from _pytask.outcomes import ExitCode from _pytask.parametrize import _arg_value_to_id_component from _pytask.parametrize import _parse_arg_names from _pytask.parametrize import _parse_parametrize_markers from _pytask.parametrize import pytask_parametrize_task from _pytask.pluginmanager import get_plugin_manager from pytask import cli +from pytask import ExitCode from pytask import main +from pytask import Mark class DummySession: diff --git a/tests/test_persist.py b/tests/test_persist.py index dab7f2bd..6ee17784 100644 --- a/tests/test_persist.py +++ b/tests/test_persist.py @@ -5,12 +5,12 @@ import pytest from _pytask.database import create_database from _pytask.database import State -from _pytask.outcomes import Persisted -from _pytask.outcomes import SkippedUnchanged -from _pytask.outcomes import TaskOutcome from _pytask.persist import pytask_execute_task_process_report from pony import orm from pytask import main +from pytask import Persisted +from pytask import SkippedUnchanged +from pytask import TaskOutcome class DummyClass: diff --git a/tests/test_profile.py b/tests/test_profile.py index ff7a6efb..531d3085 100644 --- a/tests/test_profile.py +++ b/tests/test_profile.py @@ -6,10 +6,10 @@ import pytest from _pytask.cli import cli from _pytask.database import create_database -from _pytask.outcomes import ExitCode from _pytask.profile import _to_human_readable_size from _pytask.profile import Runtime from pony import orm +from pytask import ExitCode from pytask import main diff --git a/tests/test_resolve_dependencies.py b/tests/test_resolve_dependencies.py index 62c83ae9..a556dfa6 100644 --- a/tests/test_resolve_dependencies.py +++ b/tests/test_resolve_dependencies.py @@ -9,12 +9,12 @@ import pytest from _pytask.exceptions import NodeNotFoundError from _pytask.exceptions import ResolvingDependenciesError -from _pytask.nodes import FilePathNode -from _pytask.nodes import PythonFunctionTask -from _pytask.outcomes import ExitCode from _pytask.resolve_dependencies import _check_if_root_nodes_are_available from _pytask.resolve_dependencies import pytask_resolve_dependencies_create_dag from pytask import cli +from pytask import ExitCode +from pytask import FilePathNode +from pytask import PythonFunctionTask @attr.s diff --git a/tests/test_skipping.py b/tests/test_skipping.py index 202dc21e..f2509d57 100644 --- a/tests/test_skipping.py +++ b/tests/test_skipping.py @@ -4,15 +4,15 @@ from contextlib import ExitStack as does_not_raise # noqa: N813 import pytest -from _pytask.mark import Mark -from _pytask.outcomes import ExitCode -from _pytask.outcomes import Skipped -from _pytask.outcomes import SkippedAncestorFailed -from _pytask.outcomes import SkippedUnchanged -from _pytask.outcomes import TaskOutcome from _pytask.skipping import pytask_execute_task_setup from pytask import cli +from pytask import ExitCode from pytask import main +from pytask import Mark +from pytask import Skipped +from pytask import SkippedAncestorFailed +from pytask import SkippedUnchanged +from pytask import TaskOutcome class DummyClass: diff --git a/tests/test_task.py b/tests/test_task.py index 77241c2a..145ea69b 100644 --- a/tests/test_task.py +++ b/tests/test_task.py @@ -4,7 +4,7 @@ import pytest from _pytask.nodes import create_task_name -from _pytask.outcomes import ExitCode +from pytask import ExitCode from pytask import main diff --git a/tests/test_traceback.py b/tests/test_traceback.py index acf550f9..dc140f04 100644 --- a/tests/test_traceback.py +++ b/tests/test_traceback.py @@ -3,8 +3,8 @@ import textwrap import pytest -from _pytask.outcomes import ExitCode from pytask import cli +from pytask import ExitCode @pytest.mark.end_to_end From b816ef9abc594b81611cd8af0f696c9318497d1a Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sun, 20 Feb 2022 22:12:40 +0100 Subject: [PATCH 08/12] Require 75% docstring coverage. --- .pre-commit-config.yaml | 2 +- src/_pytask/resolve_dependencies.py | 1 + src/_pytask/session.py | 5 +++-- src/_pytask/task.py | 2 ++ src/_pytask/task_utils.py | 3 +++ 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1c2b5db9..605f8d54 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -80,7 +80,7 @@ repos: rev: 1.5.0 hooks: - id: interrogate - args: [-v, --fail-under=40, src] + args: [-v, --fail-under=75, src] - repo: https://github.com/codespell-project/codespell rev: v2.1.0 hooks: diff --git a/src/_pytask/resolve_dependencies.py b/src/_pytask/resolve_dependencies.py index 33824c32..67f71777 100644 --- a/src/_pytask/resolve_dependencies.py +++ b/src/_pytask/resolve_dependencies.py @@ -1,3 +1,4 @@ +"""This module contains code related to resolving dependencies.""" from __future__ import annotations import itertools diff --git a/src/_pytask/session.py b/src/_pytask/session.py index 8264767a..1412743b 100644 --- a/src/_pytask/session.py +++ b/src/_pytask/session.py @@ -1,3 +1,4 @@ +"""This module contains code related to the session object.""" from __future__ import annotations from typing import Any @@ -13,9 +14,9 @@ # Location was moved from pluggy v0.13.1 to v1.0.0. try: - from pluggy.hooks import _HookRelay -except ImportError: from pluggy._hooks import _HookRelay +except ImportError: + from pluggy.hooks import _HookRelay if TYPE_CHECKING: diff --git a/src/_pytask/task.py b/src/_pytask/task.py index 627b9714..67dcf628 100644 --- a/src/_pytask/task.py +++ b/src/_pytask/task.py @@ -1,3 +1,4 @@ +"""This module contain hooks related to the ``@pytask.mark.task`` decorator.""" from __future__ import annotations from pathlib import Path @@ -12,6 +13,7 @@ @hookimpl def pytask_parse_config(config: dict[str, Any]) -> None: + """Parse the configuration.""" config["markers"]["task"] = "Mark a function as a task regardless of its name." diff --git a/src/_pytask/task_utils.py b/src/_pytask/task_utils.py index e9927866..81c9ec65 100644 --- a/src/_pytask/task_utils.py +++ b/src/_pytask/task_utils.py @@ -1,3 +1,4 @@ +"""This module contains utilities related to the ``@pytask.mark.task`` decorator.""" from __future__ import annotations from typing import Any @@ -8,10 +9,12 @@ def task(name: str | None = None) -> str: + """Parse inputs of the ``@pytask.mark.task`` decorator.""" return name def parse_task_marker(obj: Callable[..., Any]) -> str: + """Parse the ``@pytask.mark.task`` decorator.""" obj, task_markers = remove_markers_from_func(obj, "task") if len(task_markers) != 1: From b6bca31f032ce9e4cb8072631ecf119c5c9ac8a2 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sun, 20 Feb 2022 22:18:54 +0100 Subject: [PATCH 09/12] Remove setup.py. --- .pre-commit-config.yaml | 3 ++- pyproject.toml | 1 + setup.py | 7 ------- 3 files changed, 3 insertions(+), 8 deletions(-) delete mode 100644 setup.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 605f8d54..11fb88c4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -80,7 +80,8 @@ repos: rev: 1.5.0 hooks: - id: interrogate - args: [-v, --fail-under=75, src] + args: [-v, --fail-under=75] + exclude: ^(tests/|docs/) - repo: https://github.com/codespell-project/codespell rev: v2.1.0 hooks: diff --git a/pyproject.toml b/pyproject.toml index 1c8d5e6c..2e39790f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,6 @@ [build-system] requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"] +build-backend = "setuptools.build_meta" [tool.setuptools_scm] diff --git a/setup.py b/setup.py deleted file mode 100644 index c21a9ee0..00000000 --- a/setup.py +++ /dev/null @@ -1,7 +0,0 @@ -from __future__ import annotations - -from setuptools import setup - - -if __name__ == "__main__": - setup() From 74432676646b930c94e750bab10fa0c3150f57a5 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sun, 20 Feb 2022 22:22:24 +0100 Subject: [PATCH 10/12] fix. --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 11fb88c4..5d0f8d2c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -91,6 +91,7 @@ repos: rev: "0.47" hooks: - id: check-manifest + additional_dependencies: ["virtualenv[build]"] - repo: https://github.com/guilatrova/tryceratops rev: v1.0.1 hooks: From 6206e586899994decb592965a2e06240bfc4be3a Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sun, 20 Feb 2022 22:28:16 +0100 Subject: [PATCH 11/12] fix. --- .pre-commit-config.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5d0f8d2c..ff3d3c1d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -91,7 +91,8 @@ repos: rev: "0.47" hooks: - id: check-manifest - additional_dependencies: ["virtualenv[build]"] + args: [--no-build-isolation] + additional_dependencies: [setuptools-scm, toml] - repo: https://github.com/guilatrova/tryceratops rev: v1.0.1 hooks: From 870fd3cf62365b1786dda672b766c6ffc99a638b Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sun, 20 Feb 2022 22:40:22 +0100 Subject: [PATCH 12/12] add to changes. --- docs/source/changes.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/changes.rst b/docs/source/changes.rst index 169b26b6..5027c30c 100644 --- a/docs/source/changes.rst +++ b/docs/source/changes.rst @@ -10,6 +10,7 @@ all releases are available on `PyPI `_ and 0.1.9 - 2022-xx-xx ------------------ +- :gh:`197` publishes types, and adds classes and functions to the main namespace. - :gh:`217` enhances the tutorial on how to set up a project. - :gh:`218` removes ``depends_on`` and ``produces`` from the task function when parsed. - :gh:`219` removes some leftovers from pytest in :class:`~_pytask.mark.Mark`.