Skip to content

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

Merged
JelleZijlstra merged 3 commits intopython:mainfrom
Vikash-Kumar-23:fix-re-docs-145194
Apr 23, 2026
Merged

gh-145194: Fix typing in re tokenizer example#145198
JelleZijlstra merged 3 commits intopython:mainfrom
Vikash-Kumar-23:fix-re-docs-145194

Conversation

@Vikash-Kumar-23
Copy link
Copy Markdown
Contributor

@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
Copy Markdown

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
@JelleZijlstra JelleZijlstra added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Apr 23, 2026
@JelleZijlstra JelleZijlstra merged commit bd7352d into python:main Apr 23, 2026
33 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Apr 23, 2026
@miss-islington-app
Copy link
Copy Markdown

Thanks @Vikash-Kumar-23 for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented Apr 23, 2026

GH-148897 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Apr 23, 2026
@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented Apr 23, 2026

GH-148898 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Apr 23, 2026
JelleZijlstra pushed a commit that referenced this pull request Apr 23, 2026
…8897)

(cherry picked from commit bd7352d)

Co-authored-by: Vikash Kumar <163628932+Vikash-Kumar-23@users.noreply.github.com>
JelleZijlstra pushed a commit that referenced this pull request Apr 23, 2026
…8898)

(cherry picked from commit bd7352d)

Co-authored-by: Vikash Kumar <163628932+Vikash-Kumar-23@users.noreply.github.com>
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

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

2 participants