Skip to content

Conversation

@Gouvernathor
Copy link
Contributor

@Gouvernathor Gouvernathor commented Apr 12, 2024

Avoids a function call, avoid unnecessary inner parentheses.


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

@ericvsmith
Copy link
Member

I suppose the change is benign enough, although I don't think it's important enough to address. And the parens aren't unnecessary, they're required in the generator expression.

@hauntsaninja hauntsaninja merged commit f303651 into python:main Apr 14, 2024
@miss-islington-app
Copy link

Thanks @Gouvernathor for the PR, and @hauntsaninja for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 14, 2024
(cherry picked from commit f303651)

Co-authored-by: Gouvernathor <44340603+Gouvernathor@users.noreply.github.com>
@bedevere-app
Copy link

bedevere-app bot commented Apr 14, 2024

GH-117862 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Apr 14, 2024
hauntsaninja pushed a commit that referenced this pull request Apr 14, 2024
…) (#117862)

Simpler example of shallow dict export of a dataclass (GH-117812)
(cherry picked from commit f303651)

Co-authored-by: Gouvernathor <44340603+Gouvernathor@users.noreply.github.com>
@Gouvernathor Gouvernathor deleted the patch-8 branch April 14, 2024 16:50
@Gouvernathor
Copy link
Contributor Author

@ericvsmith the inner parentheses aren't superfluous in the original version, but it's unnecessary to have two sets of parentheses when you can have one set of braces, which is more readable.
Also the code is shorter, and I read that dict (and list) literals are a better practice than calls because they are faster at execution and also prevent shadowing issues. I only break that rule for building dicts using kwargs, but it's not the case here.

diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
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 issue skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants