Skip to content

Commit 0523da0

Browse files
authored
Improve ignore patterns and add test. (#19)
1 parent 42642b5 commit 0523da0

File tree

4 files changed

+42
-20
lines changed

4 files changed

+42
-20
lines changed

docs/changes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ all releases are available on `Anaconda.org <https://anaconda.org/pytask/pytask>
1414
- :gh:`17` changes the interface to subcommands, adds ``"-c/--config"`` option to pass a
1515
path to a configuration file and adds ``pytask clean``, a command to clean your
1616
project.
17+
- :gh:`18` changes the documentation theme to alabaster.
18+
- :gh:`19` adds some changes related to ignored folders.
1719
- :gh:`20` fixes copying code examples in the documentation.
1820

1921

docs/tutorials/how_to_configure_pytask.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ stable root and will store the information about tasks, dependencies, and produc
2525
the same directory as the configuration file.
2626

2727

28-
.. _tutorial_configure_markers:
29-
3028
markers
3129
-------
3230

@@ -67,9 +65,9 @@ Or, use the configuration file:
6765
.. code-block:: ini
6866
6967
# For single entries only.
70-
ignore = */some_file.py
68+
ignore = some_file.py
7169
7270
# Or single and multiple entries.
7371
ignore =
74-
*/some_directory/*
75-
*/some_file.py
72+
some_directory/*
73+
some_file.py

src/_pytask/config.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@
1616
hookimpl = pluggy.HookimplMarker("pytask")
1717

1818

19-
IGNORED_FILES_AND_FOLDERS = [
20-
"*/.git/*",
21-
"*/.hg/*",
22-
"*/.svn/*",
23-
"*/.venv/*",
24-
"*/*.egg-info/*",
25-
"*/.ipynb_checkpoints/*",
26-
"*/.mypy_cache/*",
27-
"*/.nox/*",
28-
"*/.tox/*",
29-
"*/_build/*",
30-
"*/__pycache__/*",
31-
"*/build/*",
32-
"*/dist/*",
19+
IGNORED_FOLDERS = [
20+
".git/*",
21+
".hg/*",
22+
".svn/*",
23+
".venv/*",
24+
"*.egg-info/*",
25+
".ipynb_checkpoints/*",
26+
".mypy_cache/*",
27+
".nox/*",
28+
".tox/*",
29+
"_build/*",
30+
"__pycache__/*",
31+
"build/*",
32+
"dist/*",
3333
]
3434

3535

@@ -80,7 +80,7 @@ def pytask_parse_config(config, config_from_cli, config_from_file):
8080
default=[],
8181
callback=to_list,
8282
)
83-
+ IGNORED_FILES_AND_FOLDERS
83+
+ IGNORED_FOLDERS
8484
)
8585

8686
config["debug_pytask"] = get_first_not_none_value(

tests/test_config.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
import pytest
55
from _pytask.config import _find_project_root_and_ini
66
from _pytask.config import _get_terminal_width
7+
from _pytask.config import IGNORED_FOLDERS
78
from pytask import main
89

910

11+
_IGNORED_FOLDERS = [i.split("/")[0] for i in IGNORED_FOLDERS]
12+
_IGNORED_FOLDERS.remove("*.egg-info")
13+
14+
1015
@pytest.mark.unit
1116
@pytest.mark.parametrize(
1217
"in_ini, paths, expected_root, expected_ini",
@@ -79,6 +84,23 @@ def test_debug_pytask(capsys, tmp_path):
7984
assert "finish pytask_execute --> None [hook]" in captured.out
8085

8186

87+
@pytest.mark.end_to_end
88+
@pytest.mark.parametrize("ignored_folder", _IGNORED_FOLDERS + ["pytask.egg-info"])
89+
def test_ignore_default_paths(tmp_path, ignored_folder):
90+
source = """
91+
def task_dummy():
92+
pass
93+
"""
94+
tmp_path.joinpath(ignored_folder).mkdir()
95+
tmp_path.joinpath(ignored_folder, "task_dummy.py").write_text(
96+
textwrap.dedent(source)
97+
)
98+
99+
session = main({"paths": tmp_path})
100+
assert session.exit_code == 0
101+
assert len(session.tasks) == 0
102+
103+
82104
@pytest.mark.end_to_end
83105
@pytest.mark.parametrize("config_path", ["pytask.ini", "tox.ini", "setup.cfg"])
84106
@pytest.mark.parametrize("ignore", ["", "*task_dummy.py"])

0 commit comments

Comments
 (0)