File tree 4 files changed +22
-1
lines changed
4 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and
56
56
{func}` pytask.is_task_function ` .
57
57
- {pull}` 438 ` clarifies some types.
58
58
- {pull}` 440 ` refines more types.
59
+ - {pull}` 442 ` allows users to import ` from pytask import mark ` and use ` @mark.skip ` .
59
60
60
61
## 0.3.2 - 2023-06-07
61
62
Original file line number Diff line number Diff line change 22
22
from _pytask .console import get_file
23
23
from _pytask .console import is_jupyter
24
24
from _pytask .exceptions import CollectionError
25
+ from _pytask .mark import MarkGenerator
25
26
from _pytask .mark_utils import has_mark
26
27
from _pytask .node_protocols import PNode
27
28
from _pytask .node_protocols import PPathNode
@@ -183,6 +184,12 @@ def pytask_collect_file(
183
184
184
185
collected_reports = []
185
186
for name , obj in inspect .getmembers (mod ):
187
+ # Skip mark generator since it overrides __getattr__ and seems like any
188
+ # object. Happens when people do ``from pytask import mark`` and
189
+ # ``@mark.x``.
190
+ if isinstance (obj , MarkGenerator ):
191
+ continue
192
+
186
193
# Ensures that tasks with this decorator are only collected once.
187
194
if has_mark (obj , "task" ):
188
195
continue
Original file line number Diff line number Diff line change @@ -31,7 +31,6 @@ def from_exception(
31
31
exc_info : OptionalExceptionInfo ,
32
32
node : MetaNode | None = None ,
33
33
) -> CollectionReport :
34
- exc_info = remove_internal_traceback_frames_from_exc_info (exc_info )
35
34
return cls (outcome = outcome , node = node , exc_info = exc_info )
36
35
37
36
Original file line number Diff line number Diff line change @@ -395,3 +395,17 @@ def task_write_text(): ...
395
395
check = False ,
396
396
)
397
397
assert b"FutureWarning: '@pytask.mark.task'" in result .stdout
398
+
399
+
400
+ @pytest .mark .end_to_end ()
401
+ def test_different_mark_import (runner , tmp_path ):
402
+ source = """
403
+ from pytask import mark
404
+
405
+ @mark.skip
406
+ def task_write_text(): ...
407
+ """
408
+ tmp_path .joinpath ("task_module.py" ).write_text (textwrap .dedent (source ))
409
+ result = runner .invoke (cli , [tmp_path .as_posix ()])
410
+ assert result .exit_code == ExitCode .OK
411
+ assert "Skipped" in result .output
You can’t perform that action at this time.
0 commit comments