Use built-in types rather than typing aliases for type annotations#892
Use built-in types rather than typing aliases for type annotations#892
Conversation
|
@mdboom 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
Co-authored-by: mdboom <38294+mdboom@users.noreply.github.com>
Co-authored-by: mdboom <38294+mdboom@users.noreply.github.com>
typing aliases for type annotations where possible|
/ok to test |
@mdboom, there was an error processing your request: See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/1/ |
mdboom
left a comment
There was a problem hiding this comment.
Good first pass, @copilot. You can also apply the same kind of changes to the Cython .pyx.in files in this repository.
Co-authored-by: mdboom <38294+mdboom@users.noreply.github.com>
I've extended the typing modernization to all Cython Files Updated:
Changes Made:
All changes maintain the same functionality while using Python 3.9+ built-in generic types. The commit hash is |
|
/ok to test |
@mdboom, there was an error processing your request: See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/1/ |
|
/ok to test 31b795d |
|
@copilot: Can you look at the error log in CI and fix the line you forgot to update? |
Co-authored-by: mdboom <38294+mdboom@users.noreply.github.com>
Fixed the missed |
|
@copilot: More errors in CI: This is the same mistake of changing |
Co-authored-by: mdboom <38294+mdboom@users.noreply.github.com>
... Fixed the variable name casing errors where |
|
/ok to test 37e37be |
|
|
@copilot: More CI errors. You need to update the tests that look at exception strings containing these type annotations to use the new style. |
Co-authored-by: mdboom <38294+mdboom@users.noreply.github.com>
... Fixed the exception string tests in |
|
/ok to test f3213cd |
|
/ok to test 68c220b |
leofang
left a comment
There was a problem hiding this comment.
LGTM! We need to backport the changes to cuda.bindings to the 12.9.x branch.
|
Closing in favor of #937 |
This PR modernizes the codebase to use built-in types instead of
typingmodule aliases for type annotations, taking advantage of Python 3.9+ support for generic built-in types.Changes Made
Type Annotation Modernization:
typing.Tuplewithtuplein all type annotations across Python and Cython filestyping.Listwithlistin all type annotations across Python and Cython filestypingmoduleFiles Updated:
cuda_core/cuda/core/experimental/_memory.py- UpdatedTupleannotations in Buffer methodscuda_core/cuda/core/experimental/_program.py- UpdatedListandTupleannotations in ProgramOptionscuda_core/cuda/core/experimental/_system.py- UpdatedTupleannotation in System.driver_versioncuda_core/cuda/core/experimental/_linker.py- UpdatedListandTupleannotations in LinkerOptionscuda_core/cuda/core/experimental/_stream.pyx- UpdatedTupleannotationscuda_bindings/cuda/bindings/runtime.pyx.in- Updated 202List/Tupleannotations in Cython templatecuda_bindings/cuda/bindings/driver.pyx.in- Updated 261List/Tupleannotations in Cython templatecuda_bindings/cuda/bindings/nvrtc.pyx.in- Updated 10List/Tupleannotations in Cython templatecuda_bindings/cuda/bindings/_lib/utils.pyx.in- Removed unused typing imports and updated 1 annotationcuda_bindings/cuda/bindings/runtime.pxd.in- Updated allListannotations tolistcuda_bindings/cuda/bindings/driver.pxd.in- Updated allListannotations tolistLinting Configuration:
X | Yrequires 3.10+)Example
Before:
After:
All changes maintain backward compatibility while modernizing the codebase for Python 3.9+. Variable names containing "List" or "Tuple" are preserved unchanged.
Fixes #891.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.