Skip to content

Need to support @overload in non-stub files #175

Closed
@gvanrossum

Description

@gvanrossum

This was brought up in python/mypy#1136 (comment) -- Tornado's utf8() function really needs to use @overload but, since they want to use inline annotations, they can't. The type would be something like

@overload
def utf8(value: None) -> None: ...
@overload
def utf8(value: bytes) -> bytes: ...
@overload
def utf8(value: str) -> bytes: ...  # or (unicode)->bytes, in PY2

This can't comfortably be expressed using type vars (at least I couldn't figure it out).

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