Skip to content

dict[K, V] does not accept empty dict {} #21

@hzhangxyz

Description

@hzhangxyz

code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from multimethod import multimethod

@multimethod
def f(a: dict[int, int]):
    pass

f({1:2})
f({})

run and get output

Traceback (most recent call last):
  File "/mnt/d/Home/Downloads/./main.py", line 11, in <module>
    f({})
  File "/mnt/d/Home/Downloads/multimethod/multimethod/__init__.py", line 188, in __call__
    return self[tuple(map(self.get_type, args))](*args, **kwargs)
  File "/mnt/d/Home/Downloads/multimethod/multimethod/__init__.py", line 184, in __missing__
    raise DispatchError(msg, types, keys)
multimethod.DispatchError: ('f: 0 methods found', (<class 'dict'>,), [])

similarly, I cannot pass empty list [] into list[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