Skip to content

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

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

gh-148991: Add colour to tokenize CLI output#148992
hugovk merged 5 commits intopython:mainfrom
hugovk:3.15-tokenize-colour

Conversation

@hugovk
Copy link
Copy Markdown
Member

@hugovk hugovk commented Apr 25, 2026

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 Outdated
Co-authored-by: Stan Ulbrych <stan@python.org>
Copy link
Copy Markdown
Member

@StanFromIreland StanFromIreland left a comment

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
150 of 152 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants