Skip to content

Commit 9bccf7d

Browse files
authored
Add rudimentary typing to pytask. (#160)
1 parent 66e9483 commit 9bccf7d

Some content is hidden

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

47 files changed

+1140
-530
lines changed

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ repos:
6666
flake8-print,
6767
flake8-pytest-style,
6868
flake8-todo,
69+
flake8-typing-imports,
6970
flake8-unused-arguments,
7071
pep8-naming,
7172
pydocstyle,
@@ -94,6 +95,21 @@ repos:
9495
hooks:
9596
- id: tryceratops
9697
exclude: (console\.py|test_mark_expression\.py)
98+
- repo: https://github.com/pre-commit/mirrors-mypy
99+
rev: 'v0.910-1'
100+
hooks:
101+
- id: mypy
102+
args: [
103+
--no-strict-optional,
104+
--ignore-missing-imports,
105+
]
106+
additional_dependencies: [
107+
types-attrs,
108+
types-click,
109+
types-setuptools
110+
]
111+
pass_filenames: false
112+
language_version: "3.9"
97113
- repo: meta
98114
hooks:
99115
- id: check-hooks-apply

docs/rtd_environment.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ dependencies:
1414
- nbsphinx
1515
- sphinx
1616
- sphinx-autoapi
17-
- sphinx-autodoc-typehints
1817
- sphinx-click
1918
- sphinx-copybutton
2019
- sphinx-panels

docs/source/changes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ all releases are available on `PyPI <https://pypi.org/project/pytask>`_ and
1111
------------------
1212

1313
- :gh:`159` removes files for creating a conda package which is handled by conda-forge.
14+
- :gh:`160` adds rudimentary typing to pytask.
1415
- :gh:`161` removes a workaround for pyreadline which is also removed in pytest 7.
1516
- :gh:`163` allow forward slashes in expressions and marker expressions.
1617
- :gh:`164` allows to use backward slashes in expressions and marker expressions.

docs/source/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
"sphinx.ext.napoleon",
4040
"sphinx.ext.viewcode",
4141
"sphinx_copybutton",
42-
"sphinx_autodoc_typehints",
4342
"sphinx_click",
4443
"sphinx_panels",
4544
"autoapi.extension",

environment.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ dependencies:
4040
- nbsphinx
4141
- sphinx
4242
- sphinx-autoapi
43-
- sphinx-autodoc-typehints
4443
- sphinx-click
4544
- sphinx-copybutton
4645
- sphinx-panels

pyproject.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,20 @@ write_to = "src/_pytask/_version.py"
88

99
[tool.tryceratops]
1010
ignore = ["TC003"]
11+
12+
13+
[tool.mypy]
14+
files = ["src", "tests"]
15+
check_untyped_defs = true
16+
disallow_any_generics = true
17+
disallow_incomplete_defs = true
18+
disallow_untyped_defs = true
19+
no_implicit_optional = true
20+
warn_redundant_casts = true
21+
warn_unused_ignores = true
22+
23+
24+
[[tool.mypy.overrides]]
25+
module = "tests.*"
26+
disallow_untyped_defs = false
27+
ignore_errors = true

src/_pytask/build.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
"""Implement the build command."""
22
import sys
3+
from typing import Any
4+
from typing import Dict
5+
from typing import TYPE_CHECKING
36

47
import click
58
from _pytask.config import hookimpl
@@ -13,13 +16,17 @@
1316
from _pytask.session import Session
1417

1518

19+
if TYPE_CHECKING:
20+
from typing import NoReturn
21+
22+
1623
@hookimpl(tryfirst=True)
17-
def pytask_extend_command_line_interface(cli):
24+
def pytask_extend_command_line_interface(cli: click.Group) -> None:
1825
"""Extend the command line interface."""
1926
cli.add_command(build)
2027

2128

22-
def main(config_from_cli):
29+
def main(config_from_cli: Dict[str, Any]) -> Session:
2330
"""Run pytask.
2431
2532
This is the main command to run pytask which usually receives kwargs from the
@@ -100,7 +107,7 @@ def main(config_from_cli):
100107
default=None,
101108
help="Print errors with tracebacks as soon as the task fails.",
102109
)
103-
def build(**config_from_cli):
110+
def build(**config_from_cli: Any) -> "NoReturn":
104111
"""Collect and execute tasks and report the results.
105112
106113
This is the default command of pytask which searches given paths or the current

0 commit comments

Comments
 (0)