Skip to content

gh-148991: Add colour to tokenize CLI output - #148992

Merged
hugovk merged 5 commits into
python:mainfrom
hugovk:3.15-tokenize-colour
Apr 26, 2026
Merged

hugovk merged 5 commits into
python:mainfrom
hugovk:3.15-tokenize-colour

Conversation

@hugovk

@hugovk hugovk commented Apr 25, 2026 •

Copy link
Copy Markdown
Member

For example, given this script which has a bit of everything:

Details
# A comment

x = 42
y = 3.14
z = 2 + 3j
name = "hello"
raw = b"bytes"
f_str = f"value: {x}"
t_str = t"template: {x}"

match x:
    case 1:
        pass

for i in range(10):
    if i % 2 == 0:
        print(i)

def greet(name: str = "world") -> None:
    ...

class Foo:
    @staticmethod
    def bar(a, b=True, *args, **kwargs):
        return a + b

lambda x: x * 2

result = [i**2 for i in range(5)]
mapping = {"key": "value", 1: None}
s = {1, 2, 3}
t = (1,)

try:
    1 / 0
except ZeroDivisionError as e:
    raise ValueError("oops") from e

async def main():
    await something()
    async for item in aiter():
        yield item

a = x if x > 0 else -x
b = x | y & z ^ ~x
c = x << 1 >> 2
d: int
e += 1  # type: ignore
image

📚 Documentation preview 📚: https://cpython-previews--148992.org.readthedocs.build/

Comment thread Lib/tokenize.py Resolved
Co-authored-by: Stan Ulbrych <stan@python.org>

@StanFromIreland StanFromIreland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hugovk
hugovk merged commit 1e7dfbc into python:main Apr 26, 2026
146 of 148 checks passed
@hugovk
hugovk deleted the 3.15-tokenize-colour branch April 26, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants