From 55faebdf7d0768b505de354de6b57e97f7bebc6d Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sat, 2 Nov 2024 20:28:50 +0100 Subject: [PATCH] Fix docs and other mentions. --- .github/workflows/update-plugin-list.yml | 2 +- .../source/how_to_guides/using_task_returns.md | 6 +++--- .../how_to_guides/writing_custom_nodes.md | 12 ++++++------ .../defining_dependencies_products.md | 12 ++++++------ .../repeating_tasks_with_different_inputs.md | 10 +++++----- docs/source/tutorials/using_a_data_catalog.md | 8 ++++---- docs/source/tutorials/write_a_task.md | 2 +- pyproject.toml | 8 ++++++-- src/_pytask/build.py | 3 +-- src/_pytask/config.py | 4 ++-- src/_pytask/logging.py | 3 +-- src/_pytask/mark/structures.py | 18 +++++++++++++----- src/_pytask/task_utils.py | 2 +- 13 files changed, 50 insertions(+), 40 deletions(-) diff --git a/.github/workflows/update-plugin-list.yml b/.github/workflows/update-plugin-list.yml index 76920b4d..27e017bb 100644 --- a/.github/workflows/update-plugin-list.yml +++ b/.github/workflows/update-plugin-list.yml @@ -26,7 +26,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: 3.12 - name: Install dependencies run: | diff --git a/docs/source/how_to_guides/using_task_returns.md b/docs/source/how_to_guides/using_task_returns.md index 669c634b..737a4bdf 100644 --- a/docs/source/how_to_guides/using_task_returns.md +++ b/docs/source/how_to_guides/using_task_returns.md @@ -26,7 +26,7 @@ defines where the return of the function, a string, should be stored. ```` -````{tab-item} Python 3.8+ +````{tab-item} Python 3.9 :sync: python38plus ```{literalinclude} ../../../docs_src/how_to_guides/using_task_returns_example_1_py38.py @@ -68,7 +68,7 @@ of the previous interfaces. ```` -````{tab-item} Python 3.8+ +````{tab-item} Python 3.9 :sync: python38plus ```{literalinclude} ../../../docs_src/how_to_guides/using_task_returns_example_3_py38.py @@ -103,7 +103,7 @@ mapped to the defined nodes. ```` -````{tab-item} Python 3.8+ +````{tab-item} Python 3.9 :sync: python38plus ```{literalinclude} ../../../docs_src/how_to_guides/using_task_returns_example_4_py38.py diff --git a/docs/source/how_to_guides/writing_custom_nodes.md b/docs/source/how_to_guides/writing_custom_nodes.md index 4befae1b..2204c0c9 100644 --- a/docs/source/how_to_guides/writing_custom_nodes.md +++ b/docs/source/how_to_guides/writing_custom_nodes.md @@ -42,7 +42,7 @@ The result will be the following task. ```` -````{tab-item} Python 3.8+ +````{tab-item} Python 3.9 :sync: python38plus ```{literalinclude} ../../../docs_src/how_to_guides/writing_custom_nodes_example_2_py38.py @@ -50,7 +50,7 @@ The result will be the following task. ```` -````{tab-item} Python 3.8+ & Return +````{tab-item} Python 3.9 & Return :sync: python38plus ```{literalinclude} ../../../docs_src/how_to_guides/writing_custom_nodes_example_2_py38_return.py @@ -87,7 +87,7 @@ we arrive at the following class. ```` -````{tab-item} Python 3.8+ +````{tab-item} Python 3.9 :sync: python38plus ```{literalinclude} ../../../docs_src/how_to_guides/writing_custom_nodes_example_3_py38.py @@ -142,9 +142,9 @@ databases. [^kedro] ## References -[^structural-subtyping]: Structural subtyping is similar to ABCs an approach in Python to enforce interfaces, but - it can be considered more pythonic since it is closer to duck typing. Hynek Schlawack - wrote a comprehensive +[^structural-subtyping]: Structural subtyping is similar to ABCs an approach in Python to enforce interfaces, + but it can be considered more pythonic since it is closer to duck typing. Hynek + Schlawack wrote a comprehensive [guide on subclassing](https://hynek.me/articles/python-subclassing-redux/) that features protocols under "Type 2". Glyph wrote an introduction to protocols called [I want a new duck](https://glyph.twistedmatrix.com/2020/07/new-duck.html). diff --git a/docs/source/tutorials/defining_dependencies_products.md b/docs/source/tutorials/defining_dependencies_products.md index 788de3c5..0c847830 100644 --- a/docs/source/tutorials/defining_dependencies_products.md +++ b/docs/source/tutorials/defining_dependencies_products.md @@ -6,8 +6,8 @@ Defining dependencies and products also serves another purpose. By analyzing the pytask determines the order to run the tasks. This tutorial offers you different interfaces. If you are comfortable with type -annotations or are not afraid to try them, look at the `Python 3.10+` or `3.8+` tabs. -You find a tutorial on type hints {doc}`here <../type_hints>`. +annotations or are not afraid to try them, look at the `Python 3.10+` or `3.9` tabs. You +find a tutorial on type hints {doc}`here <../type_hints>`. If you want to avoid type annotations for now, look at the tab named `produces`. @@ -60,7 +60,7 @@ task has finished, pytask will check whether the file exists. ```` -````{tab-item} Python 3.8+ +````{tab-item} Python 3.9 :sync: python38plus ```{literalinclude} ../../../docs_src/tutorials/defining_dependencies_products_products_py38.py @@ -117,7 +117,7 @@ annotation are dependencies of the task. ```` -````{tab-item} Python 3.8+ +````{tab-item} Python 3.9 :sync: python38plus To specify that the task relies on the data set `data.pkl`, you can add the path @@ -169,7 +169,7 @@ are assumed to point to a location relative to the task module. ```` -````{tab-item} Python 3.8+ +````{tab-item} Python 3.9 :sync: python38plus ```{literalinclude} ../../../docs_src/tutorials/defining_dependencies_products_relative_py38.py @@ -209,7 +209,7 @@ structures if needed. ```` -````{tab-item} Python 3.8+ +````{tab-item} Python 3.9 :sync: python38plus ```{literalinclude} ../../../docs_src/tutorials/defining_dependencies_products_multiple1_py38.py diff --git a/docs/source/tutorials/repeating_tasks_with_different_inputs.md b/docs/source/tutorials/repeating_tasks_with_different_inputs.md index 136152ed..bd7c9e5c 100644 --- a/docs/source/tutorials/repeating_tasks_with_different_inputs.md +++ b/docs/source/tutorials/repeating_tasks_with_different_inputs.md @@ -21,7 +21,7 @@ different seeds and output paths as default arguments of the function. ```` -````{tab-item} Python 3.8+ +````{tab-item} Python 3.9 :sync: python38plus ```{literalinclude} ../../../docs_src/tutorials/repeating_tasks_with_different_inputs1_py38.py @@ -57,7 +57,7 @@ You can also add dependencies to repeated tasks just like with any other task. ```` -````{tab-item} Python 3.8+ +````{tab-item} Python 3.9 :sync: python38plus ```{literalinclude} ../../../docs_src/tutorials/repeating_tasks_with_different_inputs2_py38.py @@ -117,7 +117,7 @@ For example, the following function is parametrized with tuples. ```` -````{tab-item} Python 3.8+ +````{tab-item} Python 3.9 :sync: python38plus ```{literalinclude} ../../../docs_src/tutorials/repeating_tasks_with_different_inputs3_py38.py @@ -158,7 +158,7 @@ a unique name for the iteration. ```` -````{tab-item} Python 3.8+ +````{tab-item} Python 3.9 :sync: python38plus ```{literalinclude} ../../../docs_src/tutorials/repeating_tasks_with_different_inputs4_py38.py @@ -244,7 +244,7 @@ Following these three tips, the parametrization becomes ```` -````{tab-item} Python 3.8+ +````{tab-item} Python 3.9 :sync: python38plus ```{literalinclude} ../../../docs_src/tutorials/repeating_tasks_with_different_inputs5_py38.py diff --git a/docs/source/tutorials/using_a_data_catalog.md b/docs/source/tutorials/using_a_data_catalog.md index d24d64d0..66b4e173 100644 --- a/docs/source/tutorials/using_a_data_catalog.md +++ b/docs/source/tutorials/using_a_data_catalog.md @@ -63,7 +63,7 @@ of our tasks. Here we see again the signature of the task function. ``` ```` -````{tab-item} Python 3.8+ +````{tab-item} Python 3.9 :sync: python38plus ```{literalinclude} ../../../docs_src/tutorials/defining_dependencies_products_products_py38.py @@ -107,7 +107,7 @@ Use `data_catalog["data"]` as an default argument to access the ```` -````{tab-item} Python 3.8+ +````{tab-item} Python 3.9 :sync: python38plus Use `data_catalog["data"]` as an default argument to access the @@ -167,7 +167,7 @@ Following one of the interfaces gives you immediate access to the ```` -````{tab-item} Python 3.8+ +````{tab-item} Python 3.9 :sync: python38plus ```{literalinclude} ../../../docs_src/tutorials/using_a_data_catalog_3_py38.py @@ -241,7 +241,7 @@ different node types which is not relevant now. ```` -````{tab-item} Python 3.8+ +````{tab-item} Python 3.9 :sync: python38plus ```{literalinclude} ../../../docs_src/tutorials/using_a_data_catalog_5_py38.py diff --git a/docs/source/tutorials/write_a_task.md b/docs/source/tutorials/write_a_task.md index 9ecc3bbc..af8f1f59 100644 --- a/docs/source/tutorials/write_a_task.md +++ b/docs/source/tutorials/write_a_task.md @@ -62,7 +62,7 @@ If you want to refresh your knowledge about type hints, read ```` -````{tab-item} Python 3.8+ +````{tab-item} Python 3.9 The task accepts the argument `path` that points to the file where the data set will be stored. The path is passed to the task via the default value, `BLD / "data.pkl"`. To diff --git a/pyproject.toml b/pyproject.toml index ba34df04..288c1ce7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,11 +11,11 @@ classifiers = [ "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Scientific/Engineering", "Topic :: Software Development :: Build Tools", ] @@ -207,7 +207,11 @@ module = ["_pytask.hookspecs"] disable_error_code = ["empty-body"] [tool.refurb] -python_version = "3.8" +python_version = "3.9" + +[[tool.refurb.amend]] +path = "src/_pytask/mark/structures.py" +ignore = ["FURB173"] [tool.coverage.report] exclude_also = [ diff --git a/src/_pytask/build.py b/src/_pytask/build.py index 2ef035c3..68f4414b 100644 --- a/src/_pytask/build.py +++ b/src/_pytask/build.py @@ -210,8 +210,7 @@ def build( # noqa: C901, PLR0912, PLR0913 "task_files": task_files, "trace": trace, "verbose": verbose, - **kwargs, - } + } | kwargs if "command" not in raw_config: pm = get_plugin_manager() diff --git a/src/_pytask/config.py b/src/_pytask/config.py index d0e2b4d4..4b897b5a 100644 --- a/src/_pytask/config.py +++ b/src/_pytask/config.py @@ -65,8 +65,8 @@ def is_file_system_case_sensitive() -> bool: def pytask_configure(pm: PluginManager, raw_config: dict[str, Any]) -> dict[str, Any]: """Configure pytask.""" # Add all values by default so that many plugins do not need to copy over values. - config = {"pm": pm, "markers": {}, **raw_config} - config["markers"] = parse_markers(config["markers"]) + config = {"pm": pm, "markers": {}} | raw_config + config["markers"] = parse_markers(config["markers"]) # type: ignore[arg-type] pm.hook.pytask_parse_config(config=config) pm.hook.pytask_post_parse(config=config) diff --git a/src/_pytask/logging.py b/src/_pytask/logging.py index bd6ea4dd..46276f5e 100644 --- a/src/_pytask/logging.py +++ b/src/_pytask/logging.py @@ -104,8 +104,7 @@ def _format_plugin_names_and_versions( # Gets us name and version! name = f"{dist.project_name}-{dist.version}" # Questionable convenience, but it keeps things short. - if name.startswith("pytask-"): - name = name[7:] + name = name.removeprefix("pytask-") # We decided to print python package names they can have more than one plugin. if name not in values: values.append(name) diff --git a/src/_pytask/mark/structures.py b/src/_pytask/mark/structures.py index d254ec31..d3762e55 100644 --- a/src/_pytask/mark/structures.py +++ b/src/_pytask/mark/structures.py @@ -20,14 +20,22 @@ @define(frozen=True) class Mark: - """A class for a mark containing the name, positional and keyword arguments.""" + """A class for a mark containing the name, positional and keyword arguments. + + Attributes + ---------- + name + Name of the mark. + args + Positional arguments of the mark decorator. + kwargs + Keyword arguments of the mark decorator. + + """ name: str - """str: Name of the mark.""" args: tuple[Any, ...] - """Tuple[Any]: Positional arguments of the mark decorator.""" kwargs: Mapping[str, Any] - """Mapping[str, Any]: Keyword arguments of the mark decorator.""" def combined_with(self, other: Mark) -> Mark: """Return a new Mark which is a combination of this Mark and another Mark. @@ -36,7 +44,7 @@ def combined_with(self, other: Mark) -> Mark: Parameters ---------- - other : pytask.mark.structures.Mark + other The mark to combine with. Returns diff --git a/src/_pytask/task_utils.py b/src/_pytask/task_utils.py index 045a1eed..4fd221ec 100644 --- a/src/_pytask/task_utils.py +++ b/src/_pytask/task_utils.py @@ -268,7 +268,7 @@ def _parse_task(task: Callable[..., Any]) -> tuple[str, Callable[..., Any]]: parsed_kwargs = _parse_task_kwargs(meta.kwargs) signature_kwargs = parse_keyword_arguments_from_signature_defaults(task) - meta.kwargs = {**signature_kwargs, **parsed_kwargs} + meta.kwargs = signature_kwargs | parsed_kwargs return parsed_name, task