Skip to content

Generic classes narrowed by @overloaded __init__ #680

Closed
python/mypy
#7860
@srittau

Description

@srittau

Quite often in typeshed we have the case that a generic class can be narrowed by the arguments provided to __init__. One example are file classes that are generic over AnyStr, where a mode argument narrows the type. It would be useful if this could be described somehow in typing, possibly by extending the @overload decorator or with some other mechanism.

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