Skip to content

Commit 2227e61

Browse files
committed
Import many stuff from typing instead of typing_extensions.
1 parent 4e3d769 commit 2227e61

File tree

72 files changed

+190
-183
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+190
-183
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ with `task_`. Here is an example.
8282
from pathlib import Path
8383

8484
from pytask import Product
85-
from typing_extensions import Annotated
85+
from typing import Annotated
8686

8787

8888
def task_hello_earth(path: Annotated[Path, Product] = Path("hello_earth.txt")):

docs/source/how_to_guides/the_data_catalog.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ The task could look like this.
110110
```python
111111
from pathlib import Path
112112
from pytask import task
113-
from typing_extensions import Annotated
113+
from typing import Annotated
114114

115115
from my_project.config import DATA_NAMES
116116
from my_project.config import MODEL_NAMES

docs/source/how_to_guides/writing_custom_nodes.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ databases. [^kedro]
142142

143143
## References
144144

145-
[^structural-subtyping]: Structural subtyping is similar to ABCs an approach in Python to enforce interfaces, but
146-
it can be considered more pythonic since it is closer to duck typing. Hynek Schlawack
147-
wrote a comprehensive
145+
[^structural-subtyping]: Structural subtyping is similar to ABCs an approach in Python to enforce interfaces,
146+
but it can be considered more pythonic since it is closer to duck typing. Hynek
147+
Schlawack wrote a comprehensive
148148
[guide on subclassing](https://hynek.me/articles/python-subclassing-redux/) that
149149
features protocols under "Type 2". Glyph wrote an introduction to protocols called
150150
[I want a new duck](https://glyph.twistedmatrix.com/2020/07/new-duck.html).

docs/source/reference_guides/api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ resolution and execution.
329329
330330
>>> from pathlib import Path
331331
>>> from pytask import Product
332-
>>> from typing_extensions import Annotated
332+
>>> from typing import Annotated
333333
>>> def task_example(path: Annotated[Path, Product]) -> None:
334334
... path.write_text("Hello, World!")
335335

docs_src/how_to_guides/bp_structure_of_task_files.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from pathlib import Path
2+
from typing import Annotated
23

34
import pandas as pd
45
from checks import perform_general_checks_on_data
5-
from typing_extensions import Annotated
66

77
from pytask import Product
88

docs_src/how_to_guides/capturing_warnings_1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from pathlib import Path
2+
from typing import Annotated
23

34
import pandas as pd
4-
from typing_extensions import Annotated
55

66
from pytask import Product
77

docs_src/how_to_guides/capturing_warnings_2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from pathlib import Path
2+
from typing import Annotated
23

34
import pandas as pd
4-
from typing_extensions import Annotated
55

66
import pytask
77
from pytask import Product

docs_src/how_to_guides/migrating_from_scripts_to_pytask_4.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Content of task_data_management.py
22
from pathlib import Path
3+
from typing import Annotated
34

45
import pandas as pd
5-
from typing_extensions import Annotated
66

77
from pytask import Product
88

docs_src/how_to_guides/migrating_from_scripts_to_pytask_5.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from pathlib import Path
2+
from typing import Annotated
23
from typing import Optional
34

45
import pandas as pd
5-
from typing_extensions import Annotated
66

77
from pytask import Product
88

docs_src/how_to_guides/provisional_products.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from pathlib import Path
2+
from typing import Annotated
23

34
import httpx
4-
from typing_extensions import Annotated
55

66
from pytask import DirectoryNode
77
from pytask import Product

docs_src/how_to_guides/provisional_task.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from pathlib import Path
2-
3-
from typing_extensions import Annotated
2+
from typing import Annotated
43

54
from pytask import DirectoryNode
65

docs_src/how_to_guides/provisional_task_generator.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from pathlib import Path
2-
3-
from typing_extensions import Annotated
2+
from typing import Annotated
43

54
from pytask import DirectoryNode
65
from pytask import task

docs_src/how_to_guides/using_task_returns_example_1_py38.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from pathlib import Path
2-
3-
from typing_extensions import Annotated
2+
from typing import Annotated
43

54

65
def task_create_file() -> Annotated[str, Path("file.txt")]:

docs_src/how_to_guides/using_task_returns_example_3_py38.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from pathlib import Path
2-
3-
from typing_extensions import Annotated
2+
from typing import Annotated
43

54

65
def task_create_files() -> Annotated[str, (Path("file1.txt"), Path("file2.txt"))]:

docs_src/how_to_guides/using_task_returns_example_4_py38.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
from typing import Annotated
12
from typing import Any
23

3-
from typing_extensions import Annotated
4-
54
from pytask import PythonNode
65

76
nodes = [

docs_src/how_to_guides/writing_custom_nodes_example_2_py38.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from pathlib import Path
2+
from typing import Annotated
23

34
import pandas as pd
4-
from typing_extensions import Annotated
55

66
from pytask import Product
77

docs_src/how_to_guides/writing_custom_nodes_example_2_py38_return.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from pathlib import Path
2+
from typing import Annotated
23

34
import pandas as pd
4-
from typing_extensions import Annotated
55

66

77
class PickleNode: ...

docs_src/tutorials/defining_dependencies_products_dependencies_py38.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from pathlib import Path
2+
from typing import Annotated
23

34
import matplotlib.pyplot as plt
45
import pandas as pd
56
from my_project.config import BLD
6-
from typing_extensions import Annotated
77

88
from pytask import Product
99

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from pathlib import Path
2-
from typing import Dict
32

43
from my_project.config import BLD
54

@@ -9,5 +8,5 @@
98
def task_plot_data(
109
path_to_data_0: Path = BLD / "data_0.pkl",
1110
path_to_data_1: Path = BLD / "data_1.pkl",
12-
produces: Dict[str, Path] = _PRODUCTS,
11+
produces: dict[str, Path] = _PRODUCTS,
1312
) -> None: ...

docs_src/tutorials/defining_dependencies_products_multiple1_py38.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from pathlib import Path
2+
from typing import Annotated
23

34
from my_project.config import BLD
4-
from typing_extensions import Annotated
55

66
from pytask import Product
77

Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from pathlib import Path
2-
from typing import Dict
2+
from typing import Annotated
33

44
from my_project.config import BLD
5-
from typing_extensions import Annotated
65

76
from pytask import Product
87

@@ -11,6 +10,6 @@
1110

1211

1312
def task_plot_data(
14-
path_to_data: Dict[str, Path] = _DEPENDENCIES,
15-
path_to_plots: Annotated[Dict[str, Path], Product] = _PRODUCTS,
13+
path_to_data: dict[str, Path] = _DEPENDENCIES,
14+
path_to_plots: Annotated[dict[str, Path], Product] = _PRODUCTS,
1615
) -> None: ...

docs_src/tutorials/defining_dependencies_products_products_py38.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from pathlib import Path
2+
from typing import Annotated
23

34
import numpy as np
45
import pandas as pd
56
from my_project.config import BLD
6-
from typing_extensions import Annotated
77

88
from pytask import Product
99

docs_src/tutorials/defining_dependencies_products_relative_py38.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from pathlib import Path
2-
3-
from typing_extensions import Annotated
2+
from typing import Annotated
43

54
from pytask import Product
65

docs_src/tutorials/repeating_tasks_with_different_inputs1_py38.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from pathlib import Path
2-
3-
from typing_extensions import Annotated
2+
from typing import Annotated
43

54
from pytask import Product
65
from pytask import task

docs_src/tutorials/repeating_tasks_with_different_inputs2_py38.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from pathlib import Path
2+
from typing import Annotated
23

34
from my_project.config import SRC
4-
from typing_extensions import Annotated
55

66
from pytask import Product
77
from pytask import task
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from pathlib import Path
2-
from typing import Tuple
32

43
from pytask import task
54

65
for seed in ((0,), (1,)):
76

87
@task
98
def task_create_random_data(
10-
produces: Path = Path(f"data_{seed[0]}.pkl"), seed: Tuple[int] = seed
9+
produces: Path = Path(f"data_{seed[0]}.pkl"), seed: tuple[int] = seed
1110
) -> None: ...
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from pathlib import Path
2-
from typing import Tuple
3-
4-
from typing_extensions import Annotated
2+
from typing import Annotated
53

64
from pytask import Product
75
from pytask import task
@@ -10,6 +8,6 @@
108

119
@task
1210
def task_create_random_data(
13-
seed: Tuple[int] = seed,
11+
seed: tuple[int] = seed,
1412
path_to_data: Annotated[Path, Product] = Path(f"data_{seed[0]}.pkl"),
1513
) -> None: ...

docs_src/tutorials/repeating_tasks_with_different_inputs4_py38.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from pathlib import Path
2-
3-
from typing_extensions import Annotated
2+
from typing import Annotated
43

54
from pytask import Product
65
from pytask import task

docs_src/tutorials/repeating_tasks_with_different_inputs5_py38.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from pathlib import Path
2+
from typing import Annotated
23
from typing import NamedTuple
34

4-
from typing_extensions import Annotated
5-
65
from pytask import Product
76
from pytask import task
87

docs_src/tutorials/skipping_tasks_example_1.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from pathlib import Path
2-
3-
from typing_extensions import Annotated
2+
from typing import Annotated
43

54
import pytask
65
from pytask import Product

docs_src/tutorials/using_a_data_catalog_2_py38.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
from typing import Annotated
2+
13
import numpy as np
24
import pandas as pd
35
from my_project.config import data_catalog
4-
from typing_extensions import Annotated
56

67
from pytask import PickleNode
78
from pytask import Product

docs_src/tutorials/using_a_data_catalog_3_py38.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from pathlib import Path
2+
from typing import Annotated
23

34
import matplotlib.pyplot as plt
45
import pandas as pd
56
from my_project.config import BLD
67
from my_project.config import data_catalog
7-
from typing_extensions import Annotated
88

99
from pytask import Product
1010

docs_src/tutorials/using_a_data_catalog_5_py38.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from pathlib import Path
2+
from typing import Annotated
23

34
import pandas as pd
45
from my_project.config import data_catalog
5-
from typing_extensions import Annotated
66

77
from pytask import PickleNode
88
from pytask import Product

docs_src/tutorials/write_a_task_py38.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Content of task_data_preparation.py.
22
from pathlib import Path
3+
from typing import Annotated
34

45
import numpy as np
56
import pandas as pd
67
from my_project.config import BLD
7-
from typing_extensions import Annotated
88

99
from pytask import Product
1010

scripts/update_plugin_list.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,17 @@
3434
import pathlib
3535
import re
3636
from textwrap import indent
37-
from typing import Generator
37+
from typing import TYPE_CHECKING
3838

3939
import httpx
4040
import packaging.version
4141
import tabulate
4242
import wcwidth
4343
from tqdm import tqdm
4444

45+
if TYPE_CHECKING:
46+
from collections.abc import Generator
47+
4548
_FILE_HEAD = r"""
4649
.. _plugin-list:
4750

src/_pytask/_inspect.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
import functools
44
import sys
55
import types
6+
from typing import TYPE_CHECKING
67
from typing import Any
78
from typing import Callable
8-
from typing import Mapping
9+
10+
if TYPE_CHECKING:
11+
from collections.abc import Mapping
912

1013
__all__ = ["get_annotations"]
1114

src/_pytask/build.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from typing import TYPE_CHECKING
1010
from typing import Any
1111
from typing import Callable
12-
from typing import Iterable
1312
from typing import Literal
1413

1514
import click
@@ -36,6 +35,7 @@
3635
from _pytask.traceback import Traceback
3736

3837
if TYPE_CHECKING:
38+
from collections.abc import Iterable
3939
from typing import NoReturn
4040

4141
from _pytask.node_protocols import PTask

0 commit comments

Comments
 (0)