Here's a typing puzzle: mypy-play.net/?mypy=latest&pyt

I want to have a method decorator that constrains the type of `self` with respect to a generic, but (obviously) does not _reduce_ the type of `self` to require that it accept any instance of the bound the decorator requires. Do I just need higher-kinded TypeVars for this (github.com/python/typing/issue) or am I missing something obvious?

Follow

@glyph I feel like half of my typing puzzles end in "you need higher kinded types". I can't tell if this means HKT are desperately needed or if it means HKT can be abused to solve a lot of problems and the lack of them is a useful constraint.

@pganssle *very* vigorously agreed here. there are definitely times when I need HKT and I'm like… why am I doing this much indirection, this is silly. but sometimes I bump into a problem like this and I feel like they're really necessary

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.