From 53d520c62392ab5a043a2529fbff30b6addf5832 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sat, 7 Jun 2025 23:31:40 +0200 Subject: [PATCH 1/4] Fix file URLs to paths and tasks. --- docs/source/changes.md | 1 + src/_pytask/console.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/source/changes.md b/docs/source/changes.md index 0e2aa95a..fe4eceab 100644 --- a/docs/source/changes.md +++ b/docs/source/changes.md @@ -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 diff --git a/src/_pytask/console.py b/src/_pytask/console.py index ed932d3f..f875ff9c 100644 --- a/src/_pytask/console.py +++ b/src/_pytask/console.py @@ -82,7 +82,7 @@ _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}", } From 79c7fee56c638f87dfa4e103929d5921a7510f6c Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sun, 8 Jun 2025 11:41:06 +0200 Subject: [PATCH 2/4] Fix tests. --- tests/test_console.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_console.py b/tests/test_console.py index d38cb60d..657ae790 100644 --- a/tests/test_console.py +++ b/tests/test_console.py @@ -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}"), ( @@ -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"), ( From a2fd8524af9d7ce467c7be2f17371d3bea662c75 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sun, 8 Jun 2025 19:33:08 +0200 Subject: [PATCH 3/4] Enable colors for Windows terminals and links. --- src/_pytask/console.py | 10 +++------- src/_pytask/logging.py | 15 --------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/_pytask/console.py b/src/_pytask/console.py index f875ff9c..e047442f 100644 --- a/src/_pytask/console.py +++ b/src/_pytask/console.py @@ -11,7 +11,6 @@ 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 @@ -55,14 +54,11 @@ ] -IS_WINDOWS_TERMINAL = "WT_SESSION" in os.environ +_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" +_IS_LEGACY_WINDOWS = _IS_WINDOWS and not _IS_WINDOWS_TERMINAL _HORIZONTAL_PADDING = (0, 1, 0, 1) @@ -108,7 +104,7 @@ ) -console: Console = Console(theme=theme, color_system=_COLOR_SYSTEM) +console: Console = Console(theme=theme) def render_to_string( diff --git a/src/_pytask/logging.py b/src/_pytask/logging.py index 46276f5e..62ab564f 100644 --- a/src/_pytask/logging.py +++ b/src/_pytask/logging.py @@ -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 @@ -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 @@ -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. From 8c0bf18b0771cf4a19c89d0feef1b88f40d0d923 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sun, 8 Jun 2025 19:38:08 +0200 Subject: [PATCH 4/4] Enable icons in Windows consoles. --- src/_pytask/console.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/_pytask/console.py b/src/_pytask/console.py index e047442f..8a450172 100644 --- a/src/_pytask/console.py +++ b/src/_pytask/console.py @@ -4,8 +4,6 @@ import functools import inspect -import os -import sys from contextlib import suppress from pathlib import Path from typing import TYPE_CHECKING @@ -54,13 +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 - - _HORIZONTAL_PADDING = (0, 1, 0, 1) @@ -70,10 +61,10 @@ """ -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] = {