Skip to content

Fix file URLs to paths and tasks and enable colors and icons on Windows. #685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 8, 2025
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
1 change: 1 addition & 0 deletions docs/source/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and
- {pull}`676` ensures compatibility with click >8.2.0.
- {pull}`680` uses uv everywhere.
- {pull}`684` adds tests for lowest and highest dependency resolutions.
- {pull}`685` fixes the file urls in task and node names.

## 0.5.3 - 2025-05-16

Expand Down
25 changes: 6 additions & 19 deletions src/_pytask/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@

import functools
import inspect
import os
import sys
from contextlib import suppress
from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any
from typing import Callable
from typing import Literal

from rich.console import Console
from rich.console import RenderableType
Expand Down Expand Up @@ -55,16 +52,6 @@
]


IS_WINDOWS_TERMINAL = "WT_SESSION" in os.environ
_IS_WINDOWS = sys.platform == "win32"


_IS_LEGACY_WINDOWS = _IS_WINDOWS and not IS_WINDOWS_TERMINAL


_COLOR_SYSTEM: Literal["auto"] | None = None if _IS_LEGACY_WINDOWS else "auto"


_HORIZONTAL_PADDING = (0, 1, 0, 1)


Expand All @@ -74,15 +61,15 @@

"""

ARROW_DOWN_ICON = "|" if _IS_LEGACY_WINDOWS else "⬇"
FILE_ICON = "" if _IS_LEGACY_WINDOWS else "📄 "
PYTHON_ICON = "" if _IS_LEGACY_WINDOWS else "🐍 "
TASK_ICON = "" if _IS_LEGACY_WINDOWS else "📝 "
ARROW_DOWN_ICON = "⬇"
FILE_ICON = "📄 "
PYTHON_ICON = "🐍 "
TASK_ICON = "📝 "


_EDITOR_URL_SCHEMES: dict[str, str] = {
"no_link": "",
"file": "file:///{path}",
"file": "file://{path}",
"vscode": "vscode://file/{path}:{line_number}",
"pycharm": "pycharm://open?file={path}&line={line_number}",
}
Expand All @@ -108,7 +95,7 @@
)


console: Console = Console(theme=theme, color_system=_COLOR_SYSTEM)
console: Console = Console(theme=theme)


def render_to_string(
Expand Down
15 changes: 0 additions & 15 deletions src/_pytask/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import contextlib
import platform
import sys
import warnings
from typing import TYPE_CHECKING
from typing import Any
from typing import NamedTuple
Expand All @@ -16,7 +15,6 @@

import _pytask
from _pytask.capture_utils import ShowCapture
from _pytask.console import IS_WINDOWS_TERMINAL
from _pytask.console import console
from _pytask.pluginmanager import hookimpl
from _pytask.reports import ExecutionReport
Expand Down Expand Up @@ -52,19 +50,6 @@ def pytask_extend_command_line_interface(cli: click.Group) -> None:
cli.commands["build"].params.append(show_locals_option)


@hookimpl
def pytask_parse_config(config: dict[str, Any]) -> None:
"""Parse configuration."""
if config["editor_url_scheme"] not in ("no_link", "file") and IS_WINDOWS_TERMINAL:
config["editor_url_scheme"] = "file"
warnings.warn(
"Windows Terminal does not support url schemes to applications, yet."
"See https://github.com/pytask-dev/pytask/issues/171 for more information. "
"Resort to `editor_url_scheme='file'`.",
stacklevel=1,
)


@hookimpl
def pytask_post_parse(config: dict[str, Any]) -> None:
# Set class variables on traceback object.
Expand Down
4 changes: 2 additions & 2 deletions tests/test_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def task_func(): ...
("edtior_url_scheme", "expected"),
[
("no_link", ""),
("file", "link file:///{path}"),
("file", "link file://{path}"),
("vscode", f"link vscode://file/{{path}}:{_SOURCE_LINE_TASK_FUNC}"),
("pycharm", f"link pycharm://open?file={{path}}&line={_SOURCE_LINE_TASK_FUNC}"),
(
Expand All @@ -56,7 +56,7 @@ def test_create_url_style_for_task(edtior_url_scheme, expected):
("edtior_url_scheme", "expected"),
[
("no_link", ""),
("file", "link file:///{path}"),
("file", "link file://{path}"),
("vscode", "link vscode://file/{path}:1"),
("pycharm", "link pycharm://open?file={path}&line=1"),
(
Expand Down