-
-
Notifications
You must be signed in to change notification settings - Fork 778
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
Add type annotation in _creation.basic #7739
Conversation
430db01
to
9d9ef46
Compare
@asi1024 Thanks for starting to work on this! Just reviewed the surface 😅
|
fd7ea15
to
bf3edd9
Compare
bf3edd9
to
4228c05
Compare
fd0697b
to
ccaf0e9
Compare
cupy/_creation/basic.py
Outdated
|
||
|
||
_OrderKACF = Literal[None, "K", "A", "C", "F"] | ||
_OrderCF = Literal[None, "C", "F"] |
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.
How about putting them under cupy.typing._types
so that they can be reused in other code?
NumPy: https://github.com/numpy/numpy/blob/e0c8bc50b262b4b8ce80b332b5349e165319cf42/numpy/__init__.pyi#L981
.pfnci/generate.py
Outdated
@@ -175,6 +175,7 @@ def generate_dockerfile(self) -> str: | |||
f'RUN pyenv install {py_spec} && \\', | |||
f' pyenv global {py_spec} && \\', | |||
' pip install -U setuptools pip wheel', | |||
' pip install mypy==1.4.1', |
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.
Let's test typing things in GitHub Actions instead of FlexCI with GPU, which is expensive.
' pip install mypy==1.4.1', |
.pfnci/windows/test.ps1
Outdated
@@ -78,7 +78,7 @@ function Main { | |||
|
|||
echo "Building..." | |||
$build_retval = 0 | |||
RunOrDie python -m pip install -U "numpy<1.24" "scipy<1.10.0" | |||
RunOrDie python -m pip install -U "numpy<1.24" "scipy<1.10.0" "mypy==1.4.1" |
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.
RunOrDie python -m pip install -U "numpy<1.24" "scipy<1.10.0" "mypy==1.4.1" | |
RunOrDie python -m pip install -U "numpy<1.24" "scipy<1.10.0" |
tests/typing_tests/.gitignore
Outdated
@@ -0,0 +1 @@ | |||
*_numpy.pyi |
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.
Question: Is it possible to generate files under the temporary directory? Or will that invalidate mypy cache?
import numpy as np | ||
import cupy as cp | ||
import cupy as xp |
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 felt difficult distinguishing xp
, cp
, np
in test cases 😅
How about this?
import numpy as np | |
import cupy as cp | |
import cupy as xp | |
import cupy as xp | |
import numpy as _np | |
import cupy as _cp |
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 agree about not using np
and cp
, but I prefer import numpy
and import cupy
without aliasing.
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.
Sounds nice!
tests/typing_tests/test_typing.py
Outdated
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.
Do we need tests/typing_tests/mypy.ini
to define the rule we should obey?
Hmm Sphinx docs seems still noisy 😢 |
ccaf0e9
to
fe9dd3d
Compare
@kmaehashi @emcastillo Ready for review! |
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.
LGTM! Only the pyi
nuance :)
/test mini |
/test mini |
CI failure seems unrelated. |
LGTM! |
Part of #4831.
Blocked by
#7738(merged).