Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #562

Merged
merged 5 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,6 @@ repos:
- id: python-check-mock-methods
- id: python-no-log-warn
- id: text-unicode-replacement-char
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.12.0
hooks:
- id: reorder-python-imports
args: [--py38-plus, --add-import, 'from __future__ import annotations']
exclude: ^(docs_src/)
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.12.0
hooks:
- id: reorder-python-imports
args: [--py38-plus]
files: ^(docs_src/)
# - repo: https://github.com/tox-dev/pyproject-fmt
# rev: 1.2.0
# hooks:
Expand All @@ -45,7 +33,7 @@ repos:
hooks:
- id: sort-all
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.0
rev: v0.3.1
hooks:
- id: ruff-format
- id: ruff
Expand Down Expand Up @@ -90,7 +78,7 @@ repos:
]
files: (docs/.)
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.1
rev: 1.8.4
hooks:
- id: nbqa-black
- id: nbqa-isort
Expand Down
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
documentation: https://www.sphinx-doc.org/en/master/usage/configuration.html

"""

from __future__ import annotations

import inspect
Expand Down
2 changes: 1 addition & 1 deletion docs/source/tutorials/making_tasks_persist.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ in the database such that the subsequent execution will skip the task successful

## When is this useful?

- You ran a formatter like Black on the files in your project and want to prevent the
- You ran a formatter like ruff on the files in your project and want to prevent the
longest-running tasks from being rerun.
- You extend a repetition of a task function but do not want to rerun all tasks.
- You want to integrate a task that you have already run elsewhere. Copy over the
Expand Down
12 changes: 6 additions & 6 deletions docs/source/tutorials/repeating_tasks_with_different_inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@ auto-generated ids are used.

### Auto-generated ids

pytask construct ids by extending the task name with representations of the values used
pytask constructs ids by extending the task name with representations of the values used
for each iteration. Booleans, floats, integers, and strings enter the task id directly.
For example, a task function that receives four arguments, `True`, `1.0`, `2`, and
`"hello"`, one of each dtype, has the following id.
`"hello"`, one of each data type, has the following id.

```
task_data_preparation.py::task_create_random_data[True-1.0-2-hello]
```

Arguments with other dtypes cannot be converted to strings and, thus, are replaced with
a combination of the argument name and the iteration counter.
Arguments with other data types cannot be converted to strings and, thus, are replaced
with a combination of the argument name and the iteration counter.

For example, the following function is parametrized with tuples.

Expand Down Expand Up @@ -136,7 +136,7 @@ For example, the following function is parametrized with tuples.

Since the tuples are not converted to strings, the ids of the two tasks are

```
```text
task_data_preparation.py::task_create_random_data[seed0]
task_data_preparation.py::task_create_random_data[seed1]
```
Expand Down Expand Up @@ -177,7 +177,7 @@ a unique name for the iteration.

produces these ids

```
```text
task_data_preparation.py::task_create_random_data[first]
task_data_preparation.py::task_create_random_data[second]
```
Expand Down
10 changes: 5 additions & 5 deletions docs/source/tutorials/using_a_data_catalog.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ The following tabs show you how to use the data catalog given the interface you
````{tab-item} Python 3.10+
:sync: python310plus

Use `data_catalog["key"]` as an default argument to access the
Use `data_catalog["data"]` as an default argument to access the
{class}`~pytask.PickleNode` within the task. When you are done transforming your
{class}`~pandas.DataFrame`, save it with {meth}`~pytask.PickleNode.save`.

Expand All @@ -74,7 +74,7 @@ Use `data_catalog["key"]` as an default argument to access the
````{tab-item} Python 3.8+
:sync: python38plus

Use `data_catalog["key"]` as an default argument to access the
Use `data_catalog["data"]` as an default argument to access the
{class}`~pytask.PickleNode` within the task. When you are done transforming your
{class}`~pandas.DataFrame`, save it with {meth}`~pytask.PickleNode.save`.

Expand All @@ -87,7 +87,7 @@ Use `data_catalog["key"]` as an default argument to access the
````{tab-item} ​produces
:sync: produces

Use `data_catalog["key"]` as an default argument to access the
Use `data_catalog["data"]` as an default argument to access the
{class}`~pytask.PickleNode` within the task. When you are done transforming your
{class}`~pandas.DataFrame`, save it with {meth}`~pytask.PickleNode.save`.

Expand Down Expand Up @@ -125,7 +125,7 @@ Following one of the interfaces gives you immediate access to the
````{tab-item} Python 3.10+
:sync: python310plus

Use `data_catalog["key"]` as an default argument to access the
Use `data_catalog["data"]` as an default argument to access the
{class}`~pytask.PickleNode` within the task. When you are done transforming your
{class}`~pandas.DataFrame`, save it with {meth}`~pytask.PickleNode.save`.

Expand All @@ -138,7 +138,7 @@ Use `data_catalog["key"]` as an default argument to access the
````{tab-item} Python 3.8+
:sync: python38plus

Use `data_catalog["key"]` as an default argument to access the
Use `data_catalog["data"]` as an default argument to access the
{class}`~pytask.PickleNode` within the task. When you are done transforming your
{class}`~pandas.DataFrame`, save it with {meth}`~pytask.PickleNode.save`.

Expand Down
1 change: 0 additions & 1 deletion docs_src/how_to_guides/bp_scaling_tasks_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from my_project.config import BLD
from my_project.config import SRC


DATA = {
"data_0": {"subset": "subset_1"},
"data_1": {"subset": "subset_2"},
Expand Down
1 change: 0 additions & 1 deletion docs_src/how_to_guides/bp_scaling_tasks_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from my_project.config import BLD
from my_project.data_preparation.config import DATA


_MODELS = ["linear_probability", "logistic_model", "decision_tree"]


Expand Down
6 changes: 2 additions & 4 deletions docs_src/how_to_guides/bp_structure_of_task_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ def task_prepare_census_data(
df.to_pickle(path_to_census)


def _clean_data(df: pd.DataFrame) -> None:
...
def _clean_data(df: pd.DataFrame) -> None: ...


def _create_new_variables(df: pd.DataFrame) -> None:
...
def _create_new_variables(df: pd.DataFrame) -> None: ...
3 changes: 1 addition & 2 deletions docs_src/how_to_guides/interfaces/dependencies_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
from pytask import PathNode


def task_example(path: Annotated[Path, PathNode(path=Path("input.txt"))]) -> None:
...
def task_example(path: Annotated[Path, PathNode(path=Path("input.txt"))]) -> None: ...
3 changes: 1 addition & 2 deletions docs_src/how_to_guides/interfaces/dependencies_default.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from pathlib import Path


def task_example(path: Path = Path("input.txt")) -> None:
...
def task_example(path: Path = Path("input.txt")) -> None: ...
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@


@task(kwargs={"path": Path("input.txt")})
def task_example(path: Path) -> None:
...
def task_example(path: Path) -> None: ...
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Content of task_data_management.py
import pandas as pd


df = pd.read_csv("data.csv")

# Many operations.
Expand Down
1 change: 0 additions & 1 deletion docs_src/how_to_guides/remote_files/https.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from upath import UPath


url = UPath("https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data")


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from pytask import task


func = lambda *x: "This is the content of the text file."


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from pytask import task


func = lambda *x: "This is the first content.", "This is the second content."


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from pytask import PythonNode


nodes = [
{"first": PythonNode(name="dict1"), "second": PythonNode(name="dict2")},
(PythonNode(name="tuple1"), PythonNode(name="tuple2")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from pytask import PythonNode
from typing_extensions import Annotated


nodes = [
{"first": PythonNode(name="dict1"), "second": PythonNode(name="dict2")},
(PythonNode(name="tuple1"), PythonNode(name="tuple2")),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from pytask import PythonNode
from pytask import task


nodes = [
{"first": PythonNode(name="dict1"), "second": PythonNode(name="dict2")},
(PythonNode(name="tuple1"), PythonNode(name="tuple2")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from pytask import Product


class PickleNode:
...
class PickleNode: ...


in_node = PickleNode.from_path(Path(__file__).parent / "in.pkl")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import pandas as pd


class PickleNode:
...
class PickleNode: ...


in_node = PickleNode.from_path(Path(__file__).parent / "in.pkl")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from typing_extensions import Annotated


class PickleNode:
...
class PickleNode: ...


in_node = PickleNode.from_path(Path(__file__).parent / "in.pkl")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from typing_extensions import Annotated


class PickleNode:
...
class PickleNode: ...


in_node = PickleNode.from_path(Path(__file__).parent / "in.pkl")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@

from my_project.config import BLD


_PRODUCTS = {"first": BLD / "data_0.pkl", "second": BLD / "data_1.pkl"}


def task_plot_data(
path_to_data_0: Path = BLD / "data_0.pkl",
path_to_data_1: Path = BLD / "data_1.pkl",
produces: Dict[str, Path] = _PRODUCTS,
) -> None:
...
) -> None: ...
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ def task_plot_data(
path_to_data_1: Path = BLD / "data_1.pkl",
path_to_plot_0: Annotated[Path, Product] = BLD / "plot_0.png",
path_to_plot_1: Annotated[Path, Product] = BLD / "plot_1.png",
) -> None:
...
) -> None: ...
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ def task_plot_data(
path_to_data_1: Path = BLD / "data_1.pkl",
path_to_plot_0: Annotated[Path, Product] = BLD / "plot_0.png",
path_to_plot_1: Annotated[Path, Product] = BLD / "plot_1.png",
) -> None:
...
) -> None: ...
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@
def task_plot_data(
path_to_data: dict[str, Path] = _DEPENDENCIES,
produces: dict[str, Path] = _PRODUCTS,
) -> None:
...
) -> None: ...
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
from my_project.config import BLD
from pytask import Product


_DEPENDENCIES = {"data_0": BLD / "data_0.pkl", "data_1": BLD / "data_1.pkl"}
_PRODUCTS = {"plot_0": BLD / "plot_0.png", "plot_1": BLD / "plot_1.png"}


def task_plot_data(
path_to_data: dict[str, Path] = _DEPENDENCIES,
path_to_plots: Annotated[dict[str, Path], Product] = _PRODUCTS,
) -> None:
...
) -> None: ...
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
from pytask import Product
from typing_extensions import Annotated


_DEPENDENCIES = {"data_0": BLD / "data_0.pkl", "data_1": BLD / "data_1.pkl"}
_PRODUCTS = {"plot_0": BLD / "plot_0.png", "plot_1": BLD / "plot_1.png"}


def task_plot_data(
path_to_data: Dict[str, Path] = _DEPENDENCIES,
path_to_plots: Annotated[Dict[str, Path], Product] = _PRODUCTS,
) -> None:
...
) -> None: ...
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from pathlib import Path


def task_create_random_data(produces: Path = Path("../bld/data.pkl")) -> None:
...
def task_create_random_data(produces: Path = Path("../bld/data.pkl")) -> None: ...
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@

def task_create_random_data(
path_to_data: Annotated[Path, Product] = Path("../bld/data.pkl"),
) -> None:
...
) -> None: ...
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@

def task_create_random_data(
path_to_data: Annotated[Path, Product] = Path("../bld/data.pkl"),
) -> None:
...
) -> None: ...
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

from pytask import task


for seed in range(10):

@task
def task_create_random_data(
produces: Path = Path(f"data_{seed}.pkl"), seed: int = seed
) -> None:
...
) -> None: ...
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
from pytask import Product
from pytask import task


for seed in range(10):

@task
def task_create_random_data(
path: Annotated[Path, Product] = Path(f"data_{seed}.pkl"), seed: int = seed
) -> None:
...
) -> None: ...
Loading
Loading