python / python/typeshed

dict.__init__() and dict.update() don't match

Open
#6,056 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.1k
Forks
2.1k
Avg merge
1d 19h
Merged PRs (30d)
82

Description

https://github.com/python/typeshed/blob/196f69b27e4353b07372a6641903e6d7fe4b330f/stdlib/builtins.pyi#L807-L818

https://github.com/python/typeshed/blob/196f69b27e4353b07372a6641903e6d7fe4b330f/stdlib/builtins.pyi#L824-L829

In stubs, __init__ has 5 overloads and update() has 3 overloads. But at runtime, dict.update() accepts everything that dict.__init__ accepts. For example:

>>> d={}
>>> d.update((s.split('=') for s in ['a=b', 'c=d']), lol='wut')
>>> d
{'a': 'b', 'c': 'd', 'lol': 'wut'}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open stdlib/builtins.pyi and inspect the linked overload ranges for dict.init() and dict.update(). Reproduce the documented runtime example, then compare the accepted call shapes; done means the update() stub matches the initialization forms described by the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.