typing.get_origin behaves differently between standard collections and typing collections
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- PR merge metrics
- PR metrics pending
Description
Bug report
typing.get_origin behaves differently between standard collections, and typing collections
more specifically
get_origin(dict) is None, while get_origin(Dict) is <class 'dict'>
the same holds for other collections as well
This is true from python3.9 where support for standard collections was added
to my understanding dict should be able to be a drop-in replacement for Dict, which is not true in case relying on get_origin
I suggest updating get_origin to return the relevant class for builtin collections as opposed to None which returns today
note, this might mean a breaking change, as pointed out here, but id does make Dict and dict behave more similarly
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing typing.get_origin for dict, Dict, and the other collection pairs described in the report. Read the existing get_origin implementation and its tests, then review the discussion about the breaking-change risk. Done means the intended behavior is agreed and the relevant collection cases are covered consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100