[New-bugs-announce] [issue47030] singledispatch does not work with positional arguments with default values.

Randolf Scholz report at bugs.python.org
Tue Mar 15 14:46:49 EDT 2022


New submission from Randolf Scholz <randolf.scholz at gmail.com>:

from functools import singledispatch
from typing import Optional

@singledispatch
def load(key: Optional[str] = None, /) -> None:
    raise NotImplementedError

@load.register
def _(key: None, /) -> None:
    print(f"loaded {key=}") 

@load.register
def _(key: str, /) -> None:
    print(f"loaded {key=}")
    
load()  # TypeError: load requires at least 1 positional argument

----------
messages: 415274
nosy: randolf.scholz
priority: normal
severity: normal
status: open
title: singledispatch does not work with positional arguments with default values.
type: enhancement
versions: Python 3.10, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue47030>
_______________________________________


More information about the New-bugs-announce mailing list