Skip to content

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

Merged
picnixz merged 4 commits into
python:mainfrom
adamtheturtle:patch-2
Mar 30, 2025
Merged

gh-131885: Document that dict.setdefault takes no keyword arguments#128208
picnixz merged 4 commits into
python:mainfrom
adamtheturtle:patch-2

Conversation

@adamtheturtle

@adamtheturtleadamtheturtle commented Dec 23, 2024

Copy link
Copy Markdown
Contributor

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-appbedevere-appBot added docs Documentation in the Doc dir skip news awaiting review labels Dec 23, 2024
@adamtheturtle

Copy link
Copy Markdown
ContributorAuthor

Related: #128207

@ZeroIntensityZeroIntensity added needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes labels Mar 25, 2025

@ZeroIntensityZeroIntensity left a comment

Copy link
Copy Markdown
Member

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

Could you document this for get as well?

@ZeroIntensity I have now done that

@ZeroIntensityZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, LGTM.

@picnixzpicnixz changed the title Document that dict.setdefault takes no keyword argumentsgh-131885: Document that dict.setdefault takes no keyword argumentsMar 30, 2025

@picnixzpicnixz left a comment

Copy link
Copy Markdown
Member

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:mainMar 30, 2025
@github-project-automationgithub-project-automationBot moved this from Todo to Done in Docs PRsMar 30, 2025
@miss-islington-app

Copy link
Copy Markdown

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 <adamdangoor@gmail.com>
@bedevere-app

Copy link
Copy Markdown

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

@bedevere-appbedevere-appBot 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 <adamdangoor@gmail.com>
@bedevere-app

Copy link
Copy Markdown

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

@bedevere-appbedevere-appBot removed the needs backport to 3.12 only security fixes label Mar 30, 2025
@picnixz

Copy link
Copy Markdown
Member

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 <adamdangoor@gmail.com>
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 <adamdangoor@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docsDocumentation in the Doc dirskip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants

@adamtheturtle@picnixz@ZeroIntensity