plum: "Could not resolve the type hint of" warning, for TypeVar
Hi, thanks for the awesome library! Super useful.
I’ve been getting this warning:
Reproduce:
from typing import TypeVar
from plum import dispatch
class Foo:
...
FooClass = TypeVar("FooClass")
@dispatch
def bar(created_chat: int) -> int:
return ...
@dispatch
def bar(
foo_cls: FooClass = Foo,
) -> FooClass:
return ...
bar()
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 21 (12 by maintainers)
Note to the unwise and the unwary: @beartype and thus Plum should superficially support a
TypeVarwith either:TypeVar('FooClass', bound=Foo)).TypeVar('FooClass', Foo)).In either case, @beartype and thus Plum should reduce that
TypeVarto that bounds and those constraints. This may require @beartype 0.16.0, which I’m on the precipice of releasing this Friday. Dare I do it? I dare.As @wesselb suggests, full-blown type variable support at runtime is non-trivial in the extreme and not something anyone wants to voluntarily tackle. You’ll either need full-time grant funding for that and/or Asperger’s. I have the latter but not the former. Therefore, I’ll eventually tackle this – but only after having exhausted every other outstanding feature request and issue in @beartype. It is the highest of the high-hanging fruit. It cannot be plucked without back pain, kidney pain, a blown ACL, and a ruptured Achilles heel. Don’t go down that road, @giladbarnea.
@ilan-gold The warnings here can be ignored. Your code will run, but may not behave as expected.
Consider the following (very contrived) example: