Skip to content

gh-145194: Fix typing in re tokenizer example#145198

Open
Vikash-Kumar-23 wants to merge 2 commits intopython:mainfrom
Vikash-Kumar-23:fix-re-docs-145194
Open

gh-145194: Fix typing in re tokenizer example#145198
Vikash-Kumar-23 wants to merge 2 commits intopython:mainfrom
Vikash-Kumar-23:fix-re-docs-145194

Conversation

@Vikash-Kumar-23
Copy link

@Vikash-Kumar-23 Vikash-Kumar-23 commented Feb 25, 2026

Fixes #145194

Summary

The re documentation “Writing a Tokenizer” example converts NUMBER token values to int/float, but the Token NamedTuple annotated value as str. This PR updates the annotation to reflect the actual yielded types.

Change

  • Doc/library/re.rst: Token.value type changed from str to int | float | str.

No behavioral changes to the example; only the type annotation was updated.

Verification

  • Built docs (Windows):
    • cd Doc
    • .\make.bat html
  • Confirmed the rendered HTML in Doc\build\html\library\re.html shows value: int | float | str in the “Writing a Tokenizer” example.
  • Ran doctests for the re docs:
    • .\make.bat doctest FILE=library/re.rst (12 tests, 12 passed)

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

@python-cla-bot
Copy link

python-cla-bot bot commented Feb 25, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app bedevere-app bot added awaiting review docs Documentation in the Doc dir skip news labels Feb 25, 2026
@github-project-automation github-project-automation bot moved this to Todo in Docs PRs Feb 25, 2026
@Vikash-Kumar-23 Vikash-Kumar-23 changed the title Fix typing in re tokenizer example gh-145194: Fix typing in re tokenizer example Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

The "re" library's demonstration of writing a tokenizer has wrong typing

1 participant