gh-131885: Document that dict.setdefault takes no keyword arguments#128208
gh-131885: Document that dict.setdefault takes no keyword arguments#128208picnixz merged 4 commits intopython:mainfrom
Conversation
Running
```python
{}.setdefault("a", default=1)
```
gives:
```
TypeError: dict.setdefault() takes no keyword arguments
```
|
Related: #128207 |
ZeroIntensity
left a comment
There was a problem hiding this comment.
Sorry for the delay on the review. Could you document this for get as well?
@ZeroIntensity I have now done that |
picnixz
left a comment
There was a problem hiding this comment.
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.
|
Thanks @adamtheturtle for the PR, and @picnixz for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
…no keyword arguments (pythonGH-128208) (cherry picked from commit edfbd8c) Co-authored-by: Adam Dangoor <[email protected]>
|
GH-131893 is a backport of this pull request to the 3.13 branch. |
…no keyword arguments (pythonGH-128208) (cherry picked from commit edfbd8c) Co-authored-by: Adam Dangoor <[email protected]>
|
GH-131894 is a backport of this pull request to the 3.12 branch. |
|
Thank you for the fix! |
Running
{}.setdefault("a", default=1)gives:
*and/as needed #131885📚 Documentation preview 📚: https://cpython-previews--128208.org.readthedocs.build/en/128208/library/stdtypes.html#dict.setdefault