Skip to content

Commit 5a21ba5

Browse files
authored
Fix file URLs to paths and tasks and enable colors and icons on Windows. (#685)
1 parent 18c310d commit 5a21ba5

File tree

4 files changed

+9
-36
lines changed

4 files changed

+9
-36
lines changed

docs/source/changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and
1010
- {pull}`676` ensures compatibility with click >8.2.0.
1111
- {pull}`680` uses uv everywhere.
1212
- {pull}`684` adds tests for lowest and highest dependency resolutions.
13+
- {pull}`685` fixes the file urls in task and node names.
1314

1415
## 0.5.3 - 2025-05-16
1516

src/_pytask/console.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44

55
import functools
66
import inspect
7-
import os
8-
import sys
97
from contextlib import suppress
108
from pathlib import Path
119
from typing import TYPE_CHECKING
1210
from typing import Any
1311
from typing import Callable
14-
from typing import Literal
1512

1613
from rich.console import Console
1714
from rich.console import RenderableType
@@ -55,16 +52,6 @@
5552
]
5653

5754

58-
IS_WINDOWS_TERMINAL = "WT_SESSION" in os.environ
59-
_IS_WINDOWS = sys.platform == "win32"
60-
61-
62-
_IS_LEGACY_WINDOWS = _IS_WINDOWS and not IS_WINDOWS_TERMINAL
63-
64-
65-
_COLOR_SYSTEM: Literal["auto"] | None = None if _IS_LEGACY_WINDOWS else "auto"
66-
67-
6855
_HORIZONTAL_PADDING = (0, 1, 0, 1)
6956

7057

@@ -74,15 +61,15 @@
7461
7562
"""
7663

77-
ARROW_DOWN_ICON = "|" if _IS_LEGACY_WINDOWS else "⬇"
78-
FILE_ICON = "" if _IS_LEGACY_WINDOWS else "📄 "
79-
PYTHON_ICON = "" if _IS_LEGACY_WINDOWS else "🐍 "
80-
TASK_ICON = "" if _IS_LEGACY_WINDOWS else "📝 "
64+
ARROW_DOWN_ICON = "⬇"
65+
FILE_ICON = "📄 "
66+
PYTHON_ICON = "🐍 "
67+
TASK_ICON = "📝 "
8168

8269

8370
_EDITOR_URL_SCHEMES: dict[str, str] = {
8471
"no_link": "",
85-
"file": "file:///{path}",
72+
"file": "file://{path}",
8673
"vscode": "vscode://file/{path}:{line_number}",
8774
"pycharm": "pycharm://open?file={path}&line={line_number}",
8875
}
@@ -108,7 +95,7 @@
10895
)
10996

11097

111-
console: Console = Console(theme=theme, color_system=_COLOR_SYSTEM)
98+
console: Console = Console(theme=theme)
11299

113100

114101
def render_to_string(

src/_pytask/logging.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import contextlib
66
import platform
77
import sys
8-
import warnings
98
from typing import TYPE_CHECKING
109
from typing import Any
1110
from typing import NamedTuple
@@ -16,7 +15,6 @@
1615

1716
import _pytask
1817
from _pytask.capture_utils import ShowCapture
19-
from _pytask.console import IS_WINDOWS_TERMINAL
2018
from _pytask.console import console
2119
from _pytask.pluginmanager import hookimpl
2220
from _pytask.reports import ExecutionReport
@@ -52,19 +50,6 @@ def pytask_extend_command_line_interface(cli: click.Group) -> None:
5250
cli.commands["build"].params.append(show_locals_option)
5351

5452

55-
@hookimpl
56-
def pytask_parse_config(config: dict[str, Any]) -> None:
57-
"""Parse configuration."""
58-
if config["editor_url_scheme"] not in ("no_link", "file") and IS_WINDOWS_TERMINAL:
59-
config["editor_url_scheme"] = "file"
60-
warnings.warn(
61-
"Windows Terminal does not support url schemes to applications, yet."
62-
"See https://github.com/pytask-dev/pytask/issues/171 for more information. "
63-
"Resort to `editor_url_scheme='file'`.",
64-
stacklevel=1,
65-
)
66-
67-
6853
@hookimpl
6954
def pytask_post_parse(config: dict[str, Any]) -> None:
7055
# Set class variables on traceback object.

tests/test_console.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def task_func(): ...
3737
("edtior_url_scheme", "expected"),
3838
[
3939
("no_link", ""),
40-
("file", "link file:///{path}"),
40+
("file", "link file://{path}"),
4141
("vscode", f"link vscode://file/{{path}}:{_SOURCE_LINE_TASK_FUNC}"),
4242
("pycharm", f"link pycharm://open?file={{path}}&line={_SOURCE_LINE_TASK_FUNC}"),
4343
(
@@ -56,7 +56,7 @@ def test_create_url_style_for_task(edtior_url_scheme, expected):
5656
("edtior_url_scheme", "expected"),
5757
[
5858
("no_link", ""),
59-
("file", "link file:///{path}"),
59+
("file", "link file://{path}"),
6060
("vscode", "link vscode://file/{path}:1"),
6161
("pycharm", "link pycharm://open?file={path}&line=1"),
6262
(

0 commit comments

Comments
 (0)