TYP: cache_readonly#43252
Conversation
|
|
||
| class cache_readonly(Protocol[_F, _G]): | ||
| def __init__(self, func: Callable[[_F], _G]) -> None: ... | ||
| def __get__(self, obj: _F, typ) -> _G: ... |
There was a problem hiding this comment.
I don't know what the variable typ is.
The return value of __get__ can also be self (is that intended?):
pandas/pandas/_libs/properties.pyx
Line 23 in b9e90dc
There was a problem hiding this comment.
The return value of get can also be self (is that intended?):
Yes, this happens when you lookup cls.foo on the class rather than on an instance
There was a problem hiding this comment.
Thanks, I added an overload for this.
The current type stubs do not handle this case
pandas/pandas/_libs/properties.pyx
Line 30 in b9e90dc
If the only solution to cover this case is to return
_G | cache_readonly[_F, _G], I am inclined to not cover this case as it would make the annotations less useful (even though it would be correct): index.right would then be a union of two types.
|
If the CI failures prove hard to resolve, could we cheat and write in the .pyi something like |
I must admit, I didn't notice the many mypy failures. I will put the PR into draft mode and locally debug it until I get it working. I will ping you when it is ready :) |
I mistakenly used Some remaining |
|
see #41588 (comment) |
I'm not sure how to test this on the CI - pyright is happy on my machine: