Replies: 1 comment 1 reply
-
The problem here is that The right way to handle this sort of thing is ParamSpec from https://www.python.org/dev/peps/pep-0612/, but unfortunately mypy doesn't support that yet. In the meantime, one way that works for your simplified example would be to use |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a function which implements a generic "poll" capability, where a provided callback is called repeatedly until it returns a result, with a small sleep between attempts. I've been trying to define the generic callback as a Protocol, but I can't seem to make it work. Here's a simplified example, with the actual polling functionality removed for conciseness:
When I run mypy on this, I get:
If I replace
_Func
withCallable[..., _Result]
, it works, and that's actually sufficient for my use case, but there are other places I'd like to be able to use this approach on functions with args/kwargs, and so I'd like to figure out what I'm doing wrong here. Any thoughts?Beta Was this translation helpful? Give feedback.
All reactions