Skip to content

Array annotation repr() emits raw class paths for dtype #1341

Closed

Description

@shi-eric

Description

_ArrayAnnotationBase.__repr__() interpolates the raw dtype class object directly into the format string, producing output like:

>>> import warp as wp
>>> wp.array4d[wp.uint32]
wp.array(dtype=<class 'warp._src.types.uint32'>, ndim=4)
>>> wp.array[wp.float32]
wp.array(dtype=<class 'warp._src.types.float32'>, ndim=1)

The dtype value is a class object, and str() on a class produces the <class '...'> form.

Impact

This is user-facing because Sphinx autodoc uses repr() to render Return type fields when autodoc_typehints = "description" is set.

For example, in the Newton Physics docs, functions like create_albedo_image_output() that are annotated as -> wp.array4d[wp.uint32] render as:

Return type: wp.array(dtype=<class 'warp._src.types.uint32'>, ndim=4)

This affects any downstream project using Warp array type annotations in Sphinx-documented APIs.

Relevant code

https://github.com/NVIDIA/warp/blob/main/warp/_src/types.py#L4647-L4650

def __repr__(self):
    dtype_str = "Any" if self.dtype is Any else self.dtype  # ← raw class object
    ndim_str = "Any" if self.ndim is Any else self.ndim
    return f"wp.{self._concrete_cls.__name__}(dtype={dtype_str}, ndim={ndim_str})"

Activity

  1. self-assigned this
    on Apr 3, 2026
  2. added theissue type on Apr 3, 2026
  3. added this to the 1.12.1 milestone on Apr 3, 2026
  4. added
    bugSomething isn't working
    docsImprovements or additions to documentation
    on Apr 3, 2026
  5. added 5 commits that reference this issue on Apr 4, 2026
    496ae22
    76ee778
    f2147e0
    96dd456
    b37d7fe
  6. shi-eric commented on Apr 7, 2026

    @shi-eric
    ContributorAuthor

    A fix was deployed in 9be104c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocsImprovements or additions to documentation

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions