How to type a method decorator that returns an overloaded implementation ? #1420
Unanswered
QuentinSoubeyranAqemia
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I've been struggling to type the following code and can't understand why MyPy 1.4.0 complains of incompatible signatures.
I'm using the following
Protocol
, from here, which is reduced to the problematic part is:I then need to implement slice support in a lot of place. In most places, the slice support would be simple-minded, and writting the overload annotations, the if...clause and the code becomes very repetitve and tedious. I have written a decorator to do that:
I struggle to write a callback protocol that:
ArrayLike
protocolI found #1040 but even when adding the descriptor protocol to my callback, MyPy complains it is not compatible with the
ArrayLike
interface.This is the full code I have right now:
MyPy seems to correclty understands the type of the indexing, but still complains at definition site that this is not compatible with
ArrayLike
.Beta Was this translation helpful? Give feedback.
All reactions