python / python/typeshed

Why are the type parameters `set`, `frozenset`, `dict` and `frozendict` are generic in unbounded?

Open
#15,751 5 comments 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

Excuse me if this question may come across as stupid, but these hashed containers should only have hashable items. However, in builtins.pyi, I see that their type variables do not have an upper bound of collections.abc.Hashable. How is that so?

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

Start with the generic container definitions in builtins.pyi and compare their type parameters with the runtime behavior of set, frozenset, dict, and frozendict. Consult the relevant Python typing and collections.abc.Hashable documentation, then explain why the current unbounded parameters are intentional or identify the stub change needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
developer-experience
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.