Skip to content

gh-131885: Document that dict.setdefault takes no keyword arguments #128208

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 4 commits into from
Mar 30, 2025

Conversation

adamtheturtle
Copy link
Contributor

@adamtheturtle adamtheturtle commented Dec 23, 2024

Running

{}.setdefault("a", default=1)

gives:

TypeError: dict.setdefault() takes no keyword arguments

📚 Documentation preview 📚: https://cpython-previews--128208.org.readthedocs.build/en/128208/library/stdtypes.html#dict.setdefault

Running

```python
{}.setdefault("a", default=1)
```

gives:

```
TypeError: dict.setdefault() takes no keyword arguments
```
@bedevere-app bedevere-app bot added docs Documentation in the Doc dir skip news awaiting review labels Dec 23, 2024
@adamtheturtle
Copy link
Contributor Author

Related: #128207

@ZeroIntensity ZeroIntensity added needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes labels Mar 25, 2025
Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

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

Sorry for the delay on the review. Could you document this for get as well?

@adamtheturtle
Copy link
Contributor Author

Could you document this for get as well?

@ZeroIntensity I have now done that

Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM.

@ZeroIntensity ZeroIntensity requested a review from picnixz March 25, 2025 15:28
@picnixz picnixz changed the title Document that dict.setdefault takes no keyword arguments gh-131885: Document that dict.setdefault takes no keyword arguments Mar 30, 2025
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

We could argue that this would violate the Mapping contract and that we have a "bug". Yes it violates the contract, however, the EB has decided that this should be the guidelines (see also #129669 (comment)), so this specific change should not be blocked.

@picnixz picnixz enabled auto-merge (squash) March 30, 2025 09:18
@picnixz picnixz merged commit edfbd8c into python:main Mar 30, 2025
26 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Mar 30, 2025
@miss-islington-app
Copy link

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 30, 2025
…no keyword arguments (pythonGH-128208)

(cherry picked from commit edfbd8c)

Co-authored-by: Adam Dangoor <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Mar 30, 2025

GH-131893 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 Mar 30, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 30, 2025
…no keyword arguments (pythonGH-128208)

(cherry picked from commit edfbd8c)

Co-authored-by: Adam Dangoor <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Mar 30, 2025

GH-131894 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 Mar 30, 2025
@picnixz
Copy link
Member

picnixz commented Mar 30, 2025

Thank you for the fix!

picnixz pushed a commit that referenced this pull request Mar 30, 2025
… no keyword arguments (GH-128208) (#131893)

gh-131885: Document that `dict.setdefault` and `dict.get` take no keyword arguments (GH-128208)
(cherry picked from commit edfbd8c)

Co-authored-by: Adam Dangoor <[email protected]>
picnixz pushed a commit that referenced this pull request Mar 30, 2025
… no keyword arguments (GH-128208) (#131894)

gh-131885: Document that `dict.setdefault` and `dict.get` take no keyword arguments (GH-128208)
(cherry picked from commit edfbd8c)

Co-authored-by: Adam Dangoor <[email protected]>
seehwan pushed a commit to seehwan/cpython that referenced this pull request Apr 16, 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.

3 participants