Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dimos/core/_test_future_annotations_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from __future__ import annotations

from dimos.core.module import Module
from dimos.core.stream import In, Out # noqa
from dimos.core.stream import In, Out


class FutureData:
Expand Down
20 changes: 2 additions & 18 deletions dimos/core/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from functools import partial
import inspect
import json
import sys
import threading
from typing import (
TYPE_CHECKING,
Expand Down Expand Up @@ -392,14 +391,8 @@ def __init_subclass__(cls, **kwargs: Any) -> None:
"""
super().__init_subclass__(**kwargs)

# Get type hints for this class only (not inherited ones).
globalns = {}
for c in cls.__mro__:
if c.__module__ in sys.modules:
globalns.update(sys.modules[c.__module__].__dict__)

try:
hints = get_type_hints(cls, globalns=globalns, include_extras=True)
hints = get_type_hints(cls, include_extras=True)
except (NameError, AttributeError, TypeError):
hints = {}

Expand All @@ -413,18 +406,9 @@ def __init_subclass__(cls, **kwargs: Any) -> None:
def __init__(self, *args, **kwargs) -> None: # type: ignore[no-untyped-def]
self.ref = None # type: ignore[assignment]

# Get type hints with proper namespace resolution for subclasses
# Collect namespaces from all classes in the MRO chain
globalns = {}
for cls in self.__class__.__mro__:
if cls.__module__ in sys.modules:
globalns.update(sys.modules[cls.__module__].__dict__)

try:
hints = get_type_hints(self.__class__, globalns=globalns, include_extras=True)
hints = get_type_hints(self.__class__, include_extras=True)
except (NameError, AttributeError, TypeError):
# If we still can't resolve hints, skip type hint processing
# This can happen with complex forward references
hints = {}

for name, ann in hints.items():
Expand Down
3 changes: 1 addition & 2 deletions dimos/hardware/sensors/camera/realsense/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from dimos.core.core import rpc
from dimos.core.module import Module, ModuleConfig
from dimos.core.module_coordinator import ModuleCoordinator
from dimos.core.stream import Out
from dimos.core.transport import LCMTransport
from dimos.hardware.sensors.camera.spec import (
OPTICAL_ROTATION,
Expand All @@ -45,8 +46,6 @@
if TYPE_CHECKING:
import pyrealsense2 as rs # type: ignore[import-not-found]

from dimos.core.stream import Out


def default_base_transform() -> Transform:
"""Default identity transform for camera mounting."""
Expand Down
5 changes: 1 addition & 4 deletions dimos/hardware/sensors/camera/zed/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from dataclasses import dataclass, field
import threading
import time
from typing import TYPE_CHECKING

import cv2
import pyzed.sl as sl
Expand All @@ -27,6 +26,7 @@
from dimos.core.core import rpc
from dimos.core.module import Module, ModuleConfig
from dimos.core.module_coordinator import ModuleCoordinator
from dimos.core.stream import Out
from dimos.core.transport import LCMTransport
from dimos.hardware.sensors.camera.spec import (
OPTICAL_ROTATION,
Expand All @@ -41,9 +41,6 @@
from dimos.spec import perception
from dimos.utils.reactive import backpressure

if TYPE_CHECKING:
from dimos.core.stream import Out


def default_base_transform() -> Transform:
"""Default identity transform for camera mounting."""
Expand Down
2 changes: 1 addition & 1 deletion dimos/manipulation/grasping/graspgen_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
from dimos.core.core import rpc
from dimos.core.docker_runner import DockerModuleConfig
from dimos.core.module import Module
from dimos.core.stream import Out
from dimos.msgs.geometry_msgs import PoseArray
from dimos.msgs.std_msgs import Header
from dimos.utils.logging_config import setup_logger
from dimos.utils.transform_utils import matrix_to_pose

if TYPE_CHECKING:
from dimos.core.stream import Out
from dimos.msgs.sensor_msgs import PointCloud2

logger = setup_logger()
Expand Down
4 changes: 2 additions & 2 deletions dimos/manipulation/grasping/grasping.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
from dimos.agents.annotation import skill
from dimos.core.core import rpc
from dimos.core.module import Module
from dimos.core.stream import Out
from dimos.msgs.geometry_msgs import PoseArray
from dimos.utils.logging_config import setup_logger
from dimos.utils.transform_utils import quaternion_to_euler

if TYPE_CHECKING:
from dimos.core.stream import Out
from dimos.msgs.geometry_msgs import PoseArray
from dimos.msgs.sensor_msgs import PointCloud2

logger = setup_logger()
Expand Down
3 changes: 1 addition & 2 deletions dimos/perception/detection/type/detection2d/bbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
import hashlib
from typing import TYPE_CHECKING, Any

from typing_extensions import Self

if TYPE_CHECKING:
from typing_extensions import Self
from ultralytics.engine.results import Results # type: ignore[import-not-found]

from dimos.msgs.sensor_msgs import Image
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ known-first-party = ["dimos"]
combine-as-imports = true
force-sort-within-sections = true

[tool.ruff.lint.flake8-type-checking]
runtime-evaluated-base-classes = ["dimos.core.module.Module"]

[tool.mypy]
python_version = "3.12"
incremental = true
Expand Down
Loading