Skip to content

terminal: render file paths as OSC 8 hyperlinks#14722

Open
CNSeniorious000 wants to merge 5 commits into
pytest-dev:mainfrom
CNSeniorious000:osc8-hyperlinks
Open

terminal: render file paths as OSC 8 hyperlinks#14722
CNSeniorious000 wants to merge 5 commits into
pytest-dev:mainfrom
CNSeniorious000:osc8-hyperlinks

Conversation

@CNSeniorious000

Copy link
Copy Markdown

Add a --hyperlinks option (yes/no/auto, default auto) that wraps file paths in tracebacks as clickable OSC 8 terminal hyperlinks.

Key decisions:

  • auto gates on tw.isatty (the writer's actual file, not sys.stdout) so a non-tty sink like the pastebin plugin's StringIO stays clean even with --color=yes, which forces hasmarkup=True.
  • The URL is built via Path.as_uri() so spaces are percent-encoded and Windows paths yield file:///C:/... rather than misparsing the drive letter as a host.
  • --hyperlinks=yes is unconditional (like --color=yes); callers that reuse output as plain text (pastebin) clear tw.hyperlinks themselves.

Closes #13580.

Add a `--hyperlinks` option (yes/no/auto, default auto) that wraps file
paths in tracebacks as clickable OSC 8 terminal hyperlinks. Auto enables
them only on an interactive terminal (gated on the writer's isatty, not
sys.stdout) so captured/pastebin output stays clean.

Closes pytest-dev#13580.

Co-authored-by: Macaron V1 Venti <contact@mindlab.ltd>
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Jul 19, 2026
@CNSeniorious000
CNSeniorious000 marked this pull request as draft July 19, 2026 00:49
@CNSeniorious000
CNSeniorious000 marked this pull request as ready for review July 19, 2026 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support OSC 8 hyperlinks

1 participant