Skip to content

Commit

Permalink
chore(dev): update type check (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeertmans authored Dec 16, 2024
1 parent 5fe4e0c commit 24233da
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pyright: reportMissingTypeArgument=false
import numpy as np
from jaxtyping import Float, Int, UInt

Expand Down
1 change: 1 addition & 0 deletions differt-core/python/differt_core/_lowlevel/rt/graph.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pyright: reportMissingTypeArgument=false
from collections.abc import Iterator, Sized

import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion differt/src/differt/geometry/_triangle_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def plane(
normal = normalize(w)[0]

u, v = orthogonal_basis(
normal, # type: ignore[reportArgumentType]
normal,
normalize=True,
)

Expand Down
Empty file added differt/src/differt/py.typed
Empty file.
6 changes: 3 additions & 3 deletions differt/src/differt/rt/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
from collections.abc import Callable, Iterator, Sized
from functools import cache
from typing import Any, Generic, TypeVar
from typing import Any, TypeVar

import equinox as eqx
import jax
Expand All @@ -24,7 +24,7 @@


@typechecker
class SizedIterator(Iterator, Sized, Generic[_T]):
class SizedIterator(Iterator[_T], Sized):
"""A custom generic class that is both :class:`Iterator<collections.abc.Iterator>` and :class:`Sized<collections.abc.Sized>`.
The main purpose of this class is to be able to use
Expand Down Expand Up @@ -330,7 +330,7 @@ def rays_intersect_any_triangle(
dtype = jnp.result_type(ray_origins, ray_directions, triangle_vertices)
hit_tol = 10.0 * jnp.finfo(dtype).eps

hit_threshold = 1.0 - hit_tol # type: ignore[reportOperatorIssue]
hit_threshold = 1.0 - hit_tol

# Put 'num_triangles' axis as leading axis
triangle_vertices = jnp.moveaxis(triangle_vertices, -3, 0)
Expand Down
2 changes: 1 addition & 1 deletion differt/src/differt/scene/_triangle_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ def compute_paths( # noqa: C901
if path_candidates is None:
path_candidates = generate_all_path_candidates(
num_objects,
order, # type: ignore[reportArgumentType]
order,
)

if self.mesh.assume_quads:
Expand Down
1 change: 1 addition & 0 deletions differt/tests/em/test_utd.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pyright: reportMissingTypeArgument=false
import chex
import jax.numpy as jnp
import numpy as np
Expand Down
1 change: 1 addition & 0 deletions differt/tests/plotting/test_core.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pyright: reportMissingTypeArgument=false
from contextlib import nullcontext as does_not_raise

import numpy as np
Expand Down
4 changes: 2 additions & 2 deletions differt/tests/plotting/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
from pytest_missing_modules.plugin import MissingModulesContextGenerator


@dispatch # type: ignore[reportArgumentType]
@dispatch
def my_plot_unimplemented(**kwargs: Any) -> SceneCanvas | MplFigure | Figure: # type: ignore[reportReturnType]
"""A plot function with no backend implementation."""


@dispatch # type: ignore[reportArgumentType]
@dispatch
def my_plot(**kwargs: Any) -> SceneCanvas | MplFigure | Figure: # type: ignore[reportReturnType]
"""A plot function with dummy backend implementations."""

Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,11 @@ precision = 2
omit = ["**/*/conftest.py"]

[tool.pyright]
deprecateTypingAliases = true
include = ["differt/src/differt", "differt/tests", "differt-core/src/differt_core"]
reportIncompatibleMethodOverride = true
reportIncompatibleVariableOverride = false # Incompatible with eqx.AbstractVar
reportMissingTypeArgument = true
reportUnnecessaryTypeIgnoreComment = true
venv = ".venv"
venvPath = "."

Expand Down

0 comments on commit 24233da

Please sign in to comment.