MAINT: Array API 2024.12 typing nits#156
Conversation
9de09f9 to
bf67bb8
Compare
|
@lucascolley ready for review and merge |
| ) -> Array: # numpydoc ignore=PR01,RT01 | ||
| """See docstring in array_api_extra._delegation.""" | ||
| a, b = asarrays(a, b, xp=xp) | ||
| if TYPE_CHECKING: # Hack around pyright bug # pragma: no cover |
There was a problem hiding this comment.
given
def f(x: Array | complex) -> Array: ...
x: Array | complex
x = f(x)when you reach the end of the snippet, mypy correctly understands that x can only be Array, whereas pyright still believes it could be complex.
There was a problem hiding this comment.
ah, so is it about reusing variable names? Is there an upstream issue we can link to?
There was a problem hiding this comment.
There was a problem hiding this comment.
given the upstream answer, what would you like to do here? Use different variable names? Keep the current workarounds but remove the FIXME?
There was a problem hiding this comment.
I've replaced Array with a fully fledged Protocol. As it would vastly enlarge the scope of this PR, I instead opened a follow-up that reverts these three hacks: #159
Co-authored-by: Lucas Colley <lucas.colley8@gmail.com>
No description provided.