Skip to content
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
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ repos:
- id: debug-statements
exclude: (debugging\.py|build\.py|clean\.py|mark/__init__\.py|collect_command\.py)
- id: end-of-file-fixer
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.7.0 # Use the ref you want to point at
hooks:
- id: python-check-blanket-noqa
- id: python-check-mock-methods
- id: python-no-eval
exclude: expression.py
- id: python-no-log-warn
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
- id: text-unicode-replacement-char
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.4
hooks:
Expand Down
2 changes: 2 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ all releases are available on `Anaconda.org <https://anaconda.org/pytask/pytask>
:gh:`44`.
- :gh:`47` reduce node names in error messages while resolving dependencies.
- :gh:`50` implements correct usage of singular and plural in collection logs.
- :gh:`51` allows to invoke pytask through the Python interpreter with ``python -m
pytask`` which will add the current path to ``sys.path``.


0.0.10 - 2020-11-18
Expand Down
9 changes: 8 additions & 1 deletion docs/tutorials/how_to_invoke_pytask.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ There are two entry-points to invoke pytask.
$ pytask --version
$ pytask -h | --help

2. Invoke pytask programmatically with
2. Invoke pytask via the Python interpreter which will add the current path to the
``sys.path``.

.. code-block:: console

python -m pytask /some/task/dir

3. Invoke pytask programmatically with

.. code-block:: python

Expand Down
2 changes: 1 addition & 1 deletion src/_pytask/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ class CaptureManager:

def __init__(self, method: "_CaptureMethod") -> None:
self._method = method
self._global_capturing = None # type: Optional[MultiCapture[str]]
self._global_capturing: Optional[MultiCapture[str]] = None

def __repr__(self) -> str:
return ("<CaptureManager _method={!r} _global_capturing={!r}>").format(
Expand Down
2 changes: 1 addition & 1 deletion src/_pytask/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def pytask_log_session_header(session):

def _format_plugin_names_and_versions(plugininfo) -> List[str]:
"""Format name and version of loaded plugins."""
values = [] # type: List[str]
values: List[str] = []
for _, dist in plugininfo:
# Gets us name and version!
name = f"{dist.project_name}-{dist.version}"
Expand Down
10 changes: 4 additions & 6 deletions src/_pytask/mark/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def reject(self, expected: Sequence[TokenType]):

def expression(s: Scanner) -> ast.Expression:
if s.accept(TokenType.EOF):
ret = ast.NameConstant(False) # type: ast.expr
ret: ast.expr = ast.NameConstant(False)
else:
ret = expr(s)
s.accept(TokenType.EOF, reject=True)
Expand Down Expand Up @@ -209,11 +209,11 @@ def compile_(cls, input_: str) -> "Expression":

"""
astexpr = expression(Scanner(input_))
code = compile(
code: types.CodeType = compile(
astexpr,
filename="<pytest match expression>",
mode="eval",
) # type: types.CodeType
)
return cls(code)

def evaluate(self, matcher: Callable[[str], bool]) -> bool:
Expand All @@ -231,7 +231,5 @@ def evaluate(self, matcher: Callable[[str], bool]) -> bool:
Whether the expression matches or not.

"""
ret = eval(
self.code, {"__builtins__": {}}, MatcherAdapter(matcher)
) # type: bool
ret: bool = eval(self.code, {"__builtins__": {}}, MatcherAdapter(matcher))
return ret
2 changes: 1 addition & 1 deletion src/_pytask/mark/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def combined_with(self, other: "Mark") -> "Mark":
assert self.name == other.name

# Remember source of ids with parametrize Marks.
param_ids_from = None # type: Optional[Mark]
param_ids_from: Optional[Mark] = None
if self.name == "parametrize":
if other._has_param_ids():
param_ids_from = other
Expand Down
8 changes: 8 additions & 0 deletions src/pytask/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""The pytask entry-point."""
import sys

import pytask


if __name__ == "__main__":
sys.exit(pytask.cli())
8 changes: 8 additions & 0 deletions tests/test_execute.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import subprocess
import textwrap

import pytest
Expand All @@ -6,6 +7,13 @@
from pytask import main


@pytest.mark.end_to_end
def test_python_m_pytask(tmp_path):
source = "def task_dummy(): pass"
tmp_path.joinpath("task_dummy.py").write_text(source)
subprocess.run(["python", "-m", "pytask", tmp_path.as_posix()], check=True)


@pytest.mark.end_to_end
def test_task_did_not_produce_node(tmp_path):
source = """
Expand Down