Skip to content

Commit

Permalink
Use type instead of Type
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoferigo committed Sep 26, 2024
1 parent 81b4d0e commit 3ad87f6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
8 changes: 4 additions & 4 deletions src/jaxsim/rbda/contacts/common.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import abc
from typing import Any, Type
from typing import Any

import jaxsim.terrain
import jaxsim.typing as jtp
Expand All @@ -20,7 +20,7 @@ class ContactsState(JaxsimDataclass):

@classmethod
@abc.abstractmethod
def build(cls: Type[Self], **kwargs) -> Self:
def build(cls: type[Self], **kwargs) -> Self:
"""
Build the contact state object.
Expand All @@ -31,7 +31,7 @@ def build(cls: Type[Self], **kwargs) -> Self:

@classmethod
@abc.abstractmethod
def zero(cls: Type[Self], **kwargs) -> Self:
def zero(cls: type[Self], **kwargs) -> Self:
"""
Build a zero contact state.
Expand All @@ -55,7 +55,7 @@ class ContactsParams(JaxsimDataclass):

@classmethod
@abc.abstractmethod
def build(cls: Type[Self], **kwargs) -> Self:
def build(cls: type[Self], **kwargs) -> Self:
"""
Create a `ContactsParams` instance with specified parameters.
Expand Down
8 changes: 4 additions & 4 deletions src/jaxsim/rbda/contacts/relaxed_rigid.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import dataclasses
from typing import Any, Type
from typing import Any

import jax
import jax.numpy as jnp
Expand Down Expand Up @@ -111,7 +111,7 @@ def __eq__(self, other: RelaxedRigidContactsParams) -> bool:

@classmethod
def build(
cls: Type[Self],
cls: type[Self],
*,
time_constant: jtp.FloatLike | None = None,
damping_coefficient: jtp.FloatLike | None = None,
Expand Down Expand Up @@ -163,13 +163,13 @@ def __eq__(self, other: RelaxedRigidContactsState) -> bool:
return hash(self) == hash(other)

@classmethod
def build(cls: Type[Self]) -> Self:
def build(cls: type[Self]) -> Self:
"""Create a `RelaxedRigidContactsState` instance"""

return RelaxedRigidContactsState()

@classmethod
def zero(cls: Type[Self], *, model: js.model.JaxSimModel) -> Self:
def zero(cls: type[Self], *, model: js.model.JaxSimModel) -> Self:
"""Build a zero `RelaxedRigidContactsState` instance from a `JaxSimModel`."""

return RelaxedRigidContactsState.build()
Expand Down
8 changes: 4 additions & 4 deletions src/jaxsim/rbda/contacts/rigid.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import dataclasses
from typing import Any, Type
from typing import Any

import jax
import jax.numpy as jnp
Expand Down Expand Up @@ -55,7 +55,7 @@ def __eq__(self, other: RigidContactsParams) -> bool:

@classmethod
def build(
cls: Type[Self],
cls: type[Self],
*,
mu: jtp.FloatLike | None = None,
K: jtp.FloatLike | None = None,
Expand Down Expand Up @@ -86,13 +86,13 @@ def __eq__(self, other: RigidContactsState) -> bool:
return hash(self) == hash(other)

@classmethod
def build(cls: Type[Self]) -> Self:
def build(cls: type[Self]) -> Self:
"""Create a `RigidContactsState` instance"""

return RigidContactsState()

@classmethod
def zero(cls: Type[Self]) -> Self:
def zero(cls: type[Self]) -> Self:
"""Build a zero `RigidContactsState` instance from a `JaxSimModel`."""

return RigidContactsState.build()
Expand Down
11 changes: 5 additions & 6 deletions src/jaxsim/rbda/contacts/soft.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import dataclasses
from typing import Type

import jax
import jax.numpy as jnp
Expand Down Expand Up @@ -68,7 +67,7 @@ def __eq__(self, other: SoftContactsParams) -> bool:

@classmethod
def build(
cls: Type[Self],
cls: type[Self],
*,
K: jtp.FloatLike = 1e6,
D: jtp.FloatLike = 2_000,
Expand Down Expand Up @@ -104,7 +103,7 @@ def build(

@classmethod
def build_default_from_jaxsim_model(
cls: Type[Self],
cls: type[Self],
model: js.model.JaxSimModel,
*,
standard_gravity: jtp.FloatLike = StandardGravity,
Expand Down Expand Up @@ -386,7 +385,7 @@ def __eq__(self: Self, other: Self) -> bool:

@classmethod
def build_from_jaxsim_model(
cls: Type[Self],
cls: type[Self],
model: js.model.JaxSimModel | None = None,
tangential_deformation: jtp.MatrixLike | None = None,
) -> Self:
Expand Down Expand Up @@ -414,7 +413,7 @@ def build_from_jaxsim_model(

@classmethod
def build(
cls: Type[Self],
cls: type[Self],
*,
tangential_deformation: jtp.MatrixLike | None = None,
number_of_collidable_points: int | None = None,
Expand Down Expand Up @@ -452,7 +451,7 @@ def build(
return cls(tangential_deformation=tangential_deformation)

@classmethod
def zero(cls: Type[Self], *, model: js.model.JaxSimModel) -> Self:
def zero(cls: type[Self], *, model: js.model.JaxSimModel) -> Self:
"""
Build a zero `SoftContactsState` from a `JaxSimModel`.
Expand Down

0 comments on commit 3ad87f6

Please sign in to comment.