X Tutup
The Wayback Machine - https://web.archive.org/web/20250608212950/https://github.com/python/cpython/issues/95539
Skip to content

typing.get_origin behaves differently between standard collections and typing collections #95539

Open
@danielkatzan

Description

@danielkatzan

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup