Skip to content

gh-134026: Fix grammar description of for statement #134034

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

Merged
merged 26 commits into from
May 21, 2025

Conversation

Yash-Vijay29
Copy link
Contributor

@Yash-Vijay29 Yash-Vijay29 commented May 15, 2025

What’s changed

  • In Doc/reference/compound_stmts.rst, replaced the undefined starred_list token with the actual grammar production starred_expression_list in the for_stmt rule.

Why

Backwards compatibility

  • This is purely a docs change; there’s no impact on existing code or behavior.

Further notes



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

@python-cla-bot
Copy link

python-cla-bot bot commented May 15, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@@ -151,21 +151,22 @@ The :keyword:`!for` statement
single: : (colon); compound statement

The :keyword:`for` statement is used to iterate over the elements of a sequence
(such as a string, tuple or list) or other iterable object:
(such as a string, tuple, or list) or other iterable object:
Copy link
Contributor

Choose a reason for hiding this comment

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

Please see warnings on your pr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay yea saw it. found a "starred_expression_list" in the https://docs.python.org/3/reference/expressions.html#grammar-token-python-grammar-starred_expression_list. I will try to link it to that instead then

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@skirpichev done, i reviewed it locally and doc seems proper. starred_list is turned into starred_expression_list mentioned already in https://docs.python.org/3/reference/expressions.html#grammar-token-python-grammar-starred_expression_list

Copy link
Contributor

Choose a reason for hiding this comment

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

Why this comma? Seems unrelated to the pr content.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why this comma? Seems unrelated to the pr content.

While changing i just noticed a small grammar error and thought of fixing it. Its a small mistake but comma should be there after the tuple, I can make a separate PR for it if you want

Copy link
Contributor

Choose a reason for hiding this comment

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

@StanFromIreland, does this looks correct for you?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is an oxford comma, its usage is varied across contexts, but generally recommended in formal writing.

It is unrelated to this pr and not very important, I am not against it staying, but I wouldn't be heavily opposed to removing it either.

@skirpichev skirpichev marked this pull request as draft May 15, 2025 09:39
@Yash-Vijay29
Copy link
Contributor Author

@skirpichev do i need to fix something? i dont know what being marked as draft is suppose to imply

@skirpichev skirpichev self-requested a review May 15, 2025 10:23
Copy link
Contributor

@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.

You can mark it as ready for review whenever you feel it is. Currently it is not.

See my comments, and I recommended you read the devguide. (Sections on documentation and pr lifecycle will be particularly handy now)

@Yash-Vijay29 Yash-Vijay29 marked this pull request as ready for review May 16, 2025 04:43
@skirpichev skirpichev changed the title gh-134026: Fix for stmt docs gh-134026: Fix grammar description of for statement May 18, 2025
@skirpichev skirpichev marked this pull request as ready for review May 18, 2025 08:14
Copy link
Contributor

@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.

Minor change needed otherwise good to go

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

LGTM, but please fix long lines.

The first item provided
by the iterator is then assigned to the target list using the standard
The :token:`~python-grammar:starred_expression_list` expression is evaluated once;
it should yield an :term:`iterable` object. An :term:`iterator` is created for that iterable.
Copy link
Member

Choose a reason for hiding this comment

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

If you change this line in any case, please break it between sentences. Otherwise the line is too long. Even if the linter is silent, the recommended size is less than 80 columns.

@encukou encukou added the needs backport to 3.14 bugs and security fixes label May 21, 2025
@encukou encukou merged commit 4eacf38 into python:main May 21, 2025
30 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs May 21, 2025
@miss-islington-app
Copy link

Thanks @Yash-Vijay29 for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@encukou
Copy link
Member

encukou commented May 21, 2025

Thank you for the fix!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 21, 2025
…34034)

(cherry picked from commit 4eacf38)

Co-authored-by: Yash Vijay <yash_vijay@outlook.com>
@bedevere-app
Copy link

bedevere-app bot commented May 21, 2025

GH-134424 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 May 21, 2025
@Yash-Vijay29 Yash-Vijay29 deleted the fix-for-stmt-docs branch May 21, 2025 15:55
encukou pushed a commit that referenced this pull request May 21, 2025
GH-134424)

gh-134026: Fix grammar description of for statement (GH-134034)
(cherry picked from commit 4eacf38)

Co-authored-by: Yash Vijay <yash_vijay@outlook.com>
lkollar pushed a commit to lkollar/cpython that referenced this pull request May 26, 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 skip news
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants