Skip to content

Confusing return type in tokenize.untokenize docs #129020

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

Closed
tomasr8 opened this issue Jan 19, 2025 · 0 comments
Closed

Confusing return type in tokenize.untokenize docs #129020

tomasr8 opened this issue Jan 19, 2025 · 0 comments
Assignees
Labels
docs Documentation in the Doc dir

Comments

@tomasr8
Copy link
Member

tomasr8 commented Jan 19, 2025

Documentation

The docs for tokenize.untokenize are somewhat confusing
regarding the return type of the function. The second paragraphs says:

The reconstructed script is returned as a single string.

while the third paragraph clarifies that it can be both str and bytes:

It returns bytes, encoded using the :data:`~token.ENCODING` token, which
is the first token sequence output by :func:`.tokenize`. If there is no
encoding token in the input, it returns a str instead.

I think we should remove the first sentence (The reconstructed script is returned as a single string.)
because it's wrong and if someone is just skimming the docs they might not realize that the full
explanation is only in the next paragraph.

Linked PRs

@tomasr8 tomasr8 added the docs Documentation in the Doc dir label Jan 19, 2025
@tomasr8 tomasr8 self-assigned this Jan 19, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jan 20, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jan 20, 2025
AA-Turner pushed a commit that referenced this issue Jan 20, 2025
…` docs (GH-129021) (#129035)

gh-129020: Remove ambiguous sentence from `tokenize.untokenize` docs (GH-129021)
(cherry picked from commit bca35f0)

Co-authored-by: Tomas R <[email protected]>
AA-Turner pushed a commit that referenced this issue Jan 20, 2025
…` docs (GH-129021) (#129036)

gh-129020: Remove ambiguous sentence from `tokenize.untokenize` docs (GH-129021)
(cherry picked from commit bca35f0)

Co-authored-by: Tomas R <[email protected]>
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this issue Jan 21, 2025
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
Projects
Status: Todo
Development

No branches or pull requests

2 participants