-
Notifications
You must be signed in to change notification settings - Fork 10
MAINT: Array API 2024.12 typing nits #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
9de09f9
to
bf67bb8
Compare
@lucascolley ready for review and merge |
src/array_api_extra/_lib/_funcs.py
Outdated
@@ -385,6 +385,9 @@ def isclose( | |||
) -> 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the pyright bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, so is it about reusing variable names? Is there an upstream issue we can link to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @crusaderky !
* MAINT: Array API 2024.12 typing nits * update docstrings * Update src/array_api_extra/_lib/_utils/_helpers.py Co-authored-by: Lucas Colley <lucas.colley8@gmail.com> * Add xref to pyright bug --------- Co-authored-by: Lucas Colley <lucas.colley8@gmail.com>
No description provided.