Skip to content

Update type hints to be PEP 484 compliant - #304

Merged
sibocw merged 2 commits into
dev-v2.1.1from
warp-typehints
Jul 3, 2026
Merged

Update type hints to be PEP 484 compliant#304
sibocw merged 2 commits into
dev-v2.1.1from
warp-typehints

Conversation

@sibocw

@sibocw sibocw commented Jul 3, 2026

Copy link
Copy Markdown
Contributor
  1. Update warp type hint syntax from
@wp.kernel
def my_kernel(arr: wp.array(dtype=float)):
    ...

to

@wp.kernel
def my_kernel(arr: wp.array[float]):
    ...

which has been supported since warp 1.12.

  1. In my own code, use TypeVars for array dimensions instead of hard-coded strings. I.e., before:
def get_joint_angles(self, fly_name: str) -> Float[np.ndarray, "n_jointdofs"]:  # noqa: F821
    ...

After:

from typing import TypeVar

n_jointdofs = TypeVar("n_jointdofs")

def get_joint_angles(self, fly_name: str) -> Float[np.ndarray, "n_jointdofs"]:
    ...

(in reality all dimension typevars are defined in a new utils.typing module.

@sibocw sibocw changed the title Update type hints to be #484 compliant Update type hints to be PEP 484 compliant Jul 3, 2026
@sibocw
sibocw merged commit f408033 into dev-v2.1.1 Jul 3, 2026
5 checks passed
@sibocw sibocw added this to the v2.1.1 milestone Jul 3, 2026
@sibocw
sibocw deleted the warp-typehints branch July 3, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant