-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-133346: Make theming support in _colorize extensible #133347
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
Conversation
@@ -44,7 +49,7 @@ def from_token(cls, token: TI, line_len: list[int]) -> Self: | |||
|
|||
class ColorSpan(NamedTuple): | |||
span: Span | |||
tag: _colorize.ColorTag | |||
tag: str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little sad about this but currently Python typing cannot construct a type that is "a set of string literals from this type's attributes" and I didn't feel like repeating myself in _colorize
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:(
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, it's much nicer to specify semantic meanings rather than colours in the code.
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM I left some comments and questions but nothing blocking.
I have a request though: I think we should explore offering some semi-final non-experimental way to support this in 3.14 with proper documentation. If @hugovk is fine with this, I would like to propose a discussion in an issue and maybe with the SC. I don't particularly thing this needs a PEP by any means (my personal opinion non SC hat on) but I think that releasing 3.14 with colorize.set_theme()
with the docs being a comment is not great and maybe it is worth an exception.
Misc/NEWS.d/next/Core_and_Builtins/2025-05-04-19-46-14.gh-issue-133346.nRXi4f.rst
Show resolved
Hide resolved
Fine by me. |
import io | ||
import os | ||
import sys | ||
|
||
from collections.abc import Callable, Iterator, Mapping | ||
from dataclasses import dataclass, field, Field |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a little unfortunate for import times that this will bring a dependency on dataclasses
module to all modules that import this. :-(
See issue for design details.