Skip to content

Singledispatch return type only tracks base function #8415

Closed
@maxrothman

Description

@maxrothman

Python 3.8
Mypy: 7.6.0
issue type: bug

ffrom functools import singledispatch

@singledispatch
def f(arg) -> str:
    pass

@f.register
def _1(arg: int) -> int:
    return arg

@f.register
def _2(arg: list) -> list:
    return list(map(f, arg))

reveal_type(f(1))

Here's the code in the mypy playground

What is the actual behavior/output?

main.py:15: note: Revealed type is 'builtins.str*'

What is the behavior/output you expect?

main.py:15: note: Revealed type is 'builtins.int*'

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