Skip to content

Commit 9ec57fd

Browse files
authored
Merge branch 'main' into setuptools-scm
2 parents 37c4fe7 + bad590a commit 9ec57fd

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

docs/changes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ all releases are available on `PyPI <https://pypi.org/project/pytask>`_ and
1515
system. This facilitates cross-platform builds of projects. Deactivate the check by
1616
setting ``check_casing_of_paths = false`` in the configuration file.
1717
- :gh:`83` replaces ``versioneer`` with ``setuptools_scm``.
18+
- :gh:`84` fixes an error in the path normalization introduced by :gh:`81`.
19+
- :gh:`85` sorts collected tasks, dependencies, and products by name.
1820

1921

2022
0.0.14 - 2021-03-23

src/_pytask/collect.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,11 @@ def pytask_collect_node(session, path, node):
183183
node = Path(node)
184184
if isinstance(node, Path):
185185
if not node.is_absolute():
186-
# ``normpath`` removes ``../`` from the path which is necessary for the
187-
# casing check which will fail since ``.resolves()`` also normalizes a path.
188-
node = Path(os.path.normpath(path.parent.joinpath(node)))
186+
node = path.parent.joinpath(node)
187+
188+
# ``normpath`` removes ``../`` from the path which is necessary for the casing
189+
# check which will fail since ``.resolves()`` also normalizes a path.
190+
node = Path(os.path.normpath(node))
189191

190192
if (
191193
not IS_FILE_SYSTEM_CASE_SENSITIVE

src/_pytask/collect_command.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,25 @@ def _organize_tasks(tasks, common_ancestor):
109109

110110
task_dict = {
111111
reduced_task_name: {
112-
"depends_on": [
113-
relative_to(node.path, common_ancestor)
114-
for node in task.depends_on.values()
115-
],
116-
"produces": [
117-
relative_to(node.path, common_ancestor)
118-
for node in task.produces.values()
119-
],
112+
"depends_on": sorted(
113+
[
114+
relative_to(node.path, common_ancestor)
115+
for node in task.depends_on.values()
116+
]
117+
),
118+
"produces": sorted(
119+
[
120+
relative_to(node.path, common_ancestor)
121+
for node in task.produces.values()
122+
]
123+
),
120124
}
121125
}
122126

123127
dictionary[reduced_task_path].update(task_dict)
124128

129+
dictionary = {key: dictionary[key] for key in sorted(dictionary)}
130+
125131
return dictionary
126132

127133

tests/test_collect.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,17 @@ def test_pytask_collect_node_raises_error_if_path_is_not_correctly_cased(tmp_pat
155155

156156

157157
@pytest.mark.unit
158-
def test_pytask_collect_node_does_not_raise_error_if_path_is_not_normalized(tmp_path):
158+
@pytest.mark.parametrize("is_absolute", [True, False])
159+
def test_pytask_collect_node_does_not_raise_error_if_path_is_not_normalized(
160+
tmp_path, is_absolute
161+
):
159162
session = Session({"check_casing_of_paths": True}, None)
160163
task_path = tmp_path / "task_example.py"
161164
real_node = tmp_path / "text.txt"
165+
162166
collected_node = f"../{tmp_path.name}/text.txt"
167+
if is_absolute:
168+
collected_node = tmp_path / collected_node
163169

164170
with pytest.warns(None) as record:
165171
result = pytask_collect_node(session, task_path, collected_node)

0 commit comments

Comments
 (0)