Skip to content

support a Module type in ty_extensions for typing specific modules #2574

@KotlinIsland

Description

@KotlinIsland

Summary

from ty_extensions import Module


def get_module() ->  Module["collections.abc"]:
    from collections import abc
    
    return abc

this is already possible by using TypeOf (thank you @AlexWaygood):

from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    import collections.abc
    from ty_extensions import TypeOf

def get_module() -> TypeOf[collections.abc]:
    import collections.abc
    return collections.abc

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-decisionAwaiting a decision from a maintainerwishNot on the current roadmap; maybe in the future

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions