[doc-only] docs(cuda.core): use PEP 604 unions in docstrings - #2601
Open
aryanputta wants to merge 1 commit into
Open
[doc-only] docs(cuda.core): use PEP 604 unions in docstrings#2601aryanputta wants to merge 1 commit into
aryanputta wants to merge 1 commit into
Conversation
Docstrings across cuda_core still spelled parameter types with the pre-3.10 typing generics. Replace Union[...] and Optional[...] with the | form the rest of the package already uses, e.g. `stream : Stream | None, optional` in _memoryview.pyx. Docstrings only, so the .pyi changes are the stubgen-pyx output for the edited .pyx files and no runtime behavior moves. In _module.pyx this also realigns the max_potential_block_size docstring with its signature, which already reads int | driver.CUoccupancyB2DSize. Two code-level spellings stay as they are: - LinkerHandleT in _linker.pyx is a runtime value, not an annotation. _program.pyx builds ProgramHandleT from it with `nvrtc.nvrtcProgram | int | LinkerHandleT`, and PEP 604 `|` on the forward-reference strings it holds raises TypeError. - The union_type literal in _process_define_macro is error-message text rather than a docstring. Sequence[...] and Iterable[...] elsewhere in cuda_core are collections.abc generics and are unaffected. Signed-off-by: Aryan <aryansputta@gmail.com>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2597.
What
Replaces
Union[...]andOptional[...]incuda_coredocstrings with the PEP 604|form. 33 parameter lines across_launch_config.pyx,_module.pyx, and_program.pyx.This matches the spelling the rest of the package already uses, for example
stream : Stream | None, optionalin_memoryview.pyxandpreferred_location : int | None, optionalin_memory/_managed_memory_resource.pyx.In
_module.pyxit also brings themax_potential_block_sizedocstring back in line with its own signature, which already readsdynamic_shared_memory_needed: int | driver.CUoccupancyB2DSize.Scope
Docstrings only. Every edit is a type-descriptor substitution; the parameter names, the
, optionalsuffixes, and the surrounding prose are untouched.The
.pyihalf of the diff is thestubgen-pyxoutput for the three edited.pyxfiles, produced by running the repo's ownstubgen-pyx-cuda-corehook rather than by hand. Regenerating all 45 stubs touched only these three, so the checked-in stubs were already in sync.Two code-level spellings are deliberately left alone:
LinkerHandleTin_linker.pyxis a runtime value, not an annotation._program.pyxbuildsProgramHandleT = nvrtc.nvrtcProgram | int | LinkerHandleTfrom it, and PEP 604|applied to the forward-reference strings it holds raisesTypeError. It has to stay atyping.Unionobject.union_typeliteral in_process_define_macrois runtime error-message text rather than a docstring.Sequence[...]andIterable[...]elsewhere incuda_corearecollections.abcgenerics and are already current, so they are untouched.No release note, since nothing user-visible changes at runtime.
Verification
pre-commit run --filesover the six changed files passes, includingmypy-cuda-core,cython-lint, and the stub generation seal.Since these are docstrings that Sphinx renders, I also ran the 21 affected
Parameters/Attributesdocstrings throughsphinx.ext.napoleon.NumpyDocstringplus a docutils parse, comparing the parent commit against this one: no new docutils messages are introduced. Each rewritten pipe carries a space on both sides, so none of them forms an RST substitution reference.After this change the only remaining
Union[/Optional[occurrences incuda_coreare the two code-level ones listed above.