Skip to content

Export _aliass for dict_keys etc #29

@KotlinIsland

Description

@KotlinIsland
from _collections_abc import dict_keys as real_dict_keys
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    dict_keys = real_dict_keys  # type: ignore[misc]
else:
    from typing import _alias # noqa

    dict_keys = _alias(real_dict_keys, 2)

# test.py
def test_dict_keys():
    typ = dict_keys[str, int]
    dk1: typ = {'a': 1}.keys()
    dk:2 typ = {1: 'a'}.keys()   # type: ignore[assignment]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions