We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I tried to find a minimal example (tested with Python 3.10 and 3.11):
from multimethod import multimethod @multimethod def f(x: int | float): ... @multimethod def f(x: tuple | list): ...
│ ~/miniforge3/envs/py311/lib/python3.11/site-packages/multimethod/__init__.py:110 in │ │ __subclasscheck__ │ │ │ │ 107 │ │ │ return issubclass(origin, self.__origin__) │ │ 108 │ │ return ( # check args first to avoid a recursion error in ABCMeta │ │ 109 │ │ │ len(args) == nargs │ │ ❱ 110 │ │ │ and issubclass(origin, self.__origin__) │ │ 111 │ │ │ and all(map(issubclass, args, self.__args__)) │ │ 112 │ │ ) │ │ 113 │ │ │ │ ╭─────────────────── locals ────────────────────╮ │ │ │ args = (<class 'tuple'>, <class 'list'>) │ │ │ │ nargs = 2 │ │ │ │ origin = tuple | list │ │ │ │ self = <class 'multimethod.int | float'> │ │ │ │ subclass = <class 'multimethod.tuple | list'> │ │ │ ╰───────────────────────────────────────────────╯ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ TypeError: issubclass() arg 1 must be a class
Worth noting that this works fine:
@multimethod def f(x: Union[int, float]): ... @multimethod def f(x: tuple | list): ...
The text was updated successfully, but these errors were encountered:
Interesting, the | syntax isn't just syntactic sugar for Union. It added a new UnionType, which will need its own support.
|
Union
UnionType
Thanks for the report.
Sorry, something went wrong.
Support Union literal syntax.
f29c975
`UnionType` only works with `issubclass` as the right arg, not the left. So the `Union` implementation is reused instead. Refs #79.
No branches or pull requests
I tried to find a minimal example (tested with Python 3.10 and 3.11):
Worth noting that this works fine:
The text was updated successfully, but these errors were encountered: