Skip to content

Commit 51c8e7e

Browse files
committed
fix linting
1 parent 1e1cdce commit 51c8e7e

File tree

11 files changed

+129
-366
lines changed

11 files changed

+129
-366
lines changed

robodm/agent/executor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def ray_map_wrapper(batch):
128128
batch_dict = batch
129129

130130
batch_size = len(next(iter(batch_dict.values())))
131-
transformed_batch = {}
131+
transformed_batch: Dict[str, List[Any]] = {}
132132

133133
for i in range(batch_size):
134134
# Extract single trajectory from batch

robodm/agent/tools/config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
and helper functions for creating custom configurations.
66
"""
77

8-
from typing import Any, Dict, List, Optional
8+
from typing import Any, Callable, Dict, List, Optional
99

1010

1111
def create_vision_config(model: str = "qwen2.5-7b",
@@ -108,7 +108,7 @@ def create_custom_config(
108108
Returns:
109109
Custom configuration dictionary
110110
"""
111-
config = {}
111+
config: Dict[str, Any] = {}
112112

113113
if tool_parameters:
114114
config["tools"] = tool_parameters
@@ -232,7 +232,7 @@ def merge_configs(*configs: Dict[str, Any]) -> Dict[str, Any]:
232232
Returns:
233233
Merged configuration dictionary
234234
"""
235-
result = {}
235+
result: Dict[str, Any] = {}
236236

237237
for config in configs:
238238
if not isinstance(config, dict):
@@ -289,7 +289,7 @@ def get_default_config() -> Dict[str, Any]:
289289

290290

291291
# Configuration presets for common scenarios
292-
PRESET_CONFIGS = {
292+
PRESET_CONFIGS: Dict[str, Callable[..., Dict[str, Any]]] = {
293293
"vision": create_vision_config,
294294
"analysis": create_analysis_config,
295295
"minimal": create_minimal_config,

robodm/backend/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class StreamMetadata:
1313
feature_type: str # Using string to avoid circular imports with FeatureType
1414
encoding: str
1515
time_base: tuple[int, int] # Numerator, denominator for time base fraction
16-
additional_metadata: Dict[str, str] = None
16+
additional_metadata: Optional[Dict[str, str]] = None
1717

1818

1919
@dataclass
@@ -176,7 +176,7 @@ def seek_container(self,
176176
@abstractmethod
177177
def decode_stream_frames(self,
178178
stream_index: int,
179-
packet_data: bytes = None) -> List[Any]:
179+
packet_data: Optional[bytes] = None) -> List[Any]:
180180
"""Decode frames from a stream, optionally with packet data
181181
182182
Args:

robodm/backend/codec_config.py

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ def is_codec_config_supported(width: int,
3333
"""Check if a specific width/height/pixel format combination is supported by codec."""
3434
try:
3535
cc = av.codec.CodecContext.create(codec_name, "w")
36-
cc.width = width
37-
cc.height = height
38-
cc.pix_fmt = pix_fmt
36+
cc.width = width # type: ignore[attr-defined]
37+
cc.height = height # type: ignore[attr-defined]
38+
cc.pix_fmt = pix_fmt # type: ignore[attr-defined]
3939
cc.time_base = Fraction(1, 30)
4040
cc.open(strict=True)
4141
# Note: CodecContext doesn't have a close() method in newer PyAV versions
@@ -92,7 +92,7 @@ def is_raw_data_codec(codec_name: str) -> bool:
9292
return codec_name.startswith("rawvideo")
9393

9494
# Image codec configurations (use actual codec for container)
95-
IMAGE_CODEC_CONFIGS = {
95+
IMAGE_CODEC_CONFIGS: Dict[str, Dict[str, Any]] = {
9696
"libx264": {
9797
"container_codec": "libx264", # Use actual codec for container
9898
"pixel_format": "yuv420p",
@@ -126,7 +126,7 @@ def is_raw_data_codec(codec_name: str) -> bool:
126126
}
127127

128128
# Raw data codec configurations (always use rawvideo container)
129-
RAW_DATA_CODEC_CONFIGS = {
129+
RAW_DATA_CODEC_CONFIGS: Dict[str, Dict[str, Any]] = {
130130
"rawvideo": {
131131
"container_codec": "rawvideo", # Always rawvideo for container
132132
"internal_codec": "pickle_raw", # Default internal implementation
@@ -279,15 +279,16 @@ def get_codec_for_feature(self,
279279
is_rgb_image = (data_shape is not None and len(data_shape) == 3
280280
and data_shape[2] == 3)
281281

282-
if is_rgb_image:
282+
if is_rgb_image and data_shape is not None:
283283
# This is RGB image data - can use video codecs
284284
height, width = data_shape[0], data_shape[1]
285285

286286
# Check if a specific video codec was provided
287287
if self.video_codec and self.video_codec != "auto":
288-
if self.is_image_codec(
289-
self.video_codec) and self.is_valid_image_shape(
290-
data_shape, self.video_codec):
288+
if (self.is_image_codec(self.video_codec)
289+
and data_shape is not None
290+
and self.is_valid_image_shape(data_shape,
291+
self.video_codec)):
291292
logger.debug(
292293
f"Using specified video codec {self.video_codec} for RGB shape {data_shape}"
293294
)
@@ -299,7 +300,8 @@ def get_codec_for_feature(self,
299300

300301
# Check if user specified a general codec other than auto
301302
if self.codec != "auto" and self.is_image_codec(self.codec):
302-
if self.is_valid_image_shape(data_shape, self.codec):
303+
if data_shape is not None and self.is_valid_image_shape(
304+
data_shape, self.codec):
303305
logger.debug(
304306
f"Using user-specified image codec {self.codec} for RGB shape {data_shape}"
305307
)
@@ -318,7 +320,8 @@ def get_codec_for_feature(self,
318320
]
319321

320322
for codec in codec_preferences:
321-
if self.is_valid_image_shape(data_shape, codec):
323+
if data_shape is not None and self.is_valid_image_shape(
324+
data_shape, codec):
322325
logger.debug(
323326
f"Selected image codec {codec} for RGB shape {data_shape}"
324327
)
@@ -377,16 +380,19 @@ def _can_codec_handle_feature(self, codec: str,
377380
def get_container_codec(self, codec: str) -> str:
378381
"""Get the container codec name for a given codec."""
379382
if codec in self.IMAGE_CODEC_CONFIGS:
380-
return self.IMAGE_CODEC_CONFIGS[codec]["container_codec"]
383+
return cast(str,
384+
self.IMAGE_CODEC_CONFIGS[codec]["container_codec"])
381385
elif codec in self.RAW_DATA_CODEC_CONFIGS:
382-
return self.RAW_DATA_CODEC_CONFIGS[codec]["container_codec"]
386+
return cast(str,
387+
self.RAW_DATA_CODEC_CONFIGS[codec]["container_codec"])
383388
else:
384389
raise ValueError(f"Unknown codec {codec}")
385390

386391
def get_internal_codec(self, codec: str) -> Optional[str]:
387392
"""Get the internal codec implementation name for raw data codecs."""
388393
if codec in self.RAW_DATA_CODEC_CONFIGS:
389-
return self.RAW_DATA_CODEC_CONFIGS[codec]["internal_codec"]
394+
return cast(str,
395+
self.RAW_DATA_CODEC_CONFIGS[codec]["internal_codec"])
390396
elif codec in self.IMAGE_CODEC_CONFIGS:
391397
# Image codecs don't have internal codecs
392398
return None
@@ -402,15 +408,18 @@ def get_raw_codec_name(self, codec: str) -> str:
402408
# Fallback for backward compatibility
403409
legacy_configs = self.CODEC_CONFIGS
404410
if codec in legacy_configs:
405-
return legacy_configs[codec].get("raw_codec", "pickle_raw")
411+
return cast(str, legacy_configs[codec].get("raw_codec",
412+
"pickle_raw"))
406413

407414
return "pickle_raw"
408415

409416
def get_pixel_format(self, codec: str,
410417
feature_type: FeatureType) -> Optional[str]:
411418
"""Get appropriate pixel format for codec and feature type."""
412419
if codec in self.IMAGE_CODEC_CONFIGS:
413-
base_format = self.IMAGE_CODEC_CONFIGS[codec].get("pixel_format")
420+
base_format = cast(
421+
Optional[str],
422+
self.IMAGE_CODEC_CONFIGS[codec].get("pixel_format"))
414423

415424
# For FFV1, use RGB24 to avoid YUV conversion issues
416425
if codec == "ffv1":
@@ -434,14 +443,15 @@ def get_codec_options(self, codec: str) -> Dict[str, Any]:
434443

435444
if codec in self.IMAGE_CODEC_CONFIGS:
436445
# Video/image codec - only use video-specific options
437-
default_options = self.IMAGE_CODEC_CONFIGS[codec].get(
438-
"options", {}).copy()
446+
options_dict = self.IMAGE_CODEC_CONFIGS[codec].get("options", {})
447+
default_options = cast(Dict[str, Any], options_dict).copy()
439448
# Only merge video-specific custom options
440449
default_options.update(self.video_custom_options)
441450
elif codec in self.RAW_DATA_CODEC_CONFIGS:
442451
# Raw data codec - only use raw-specific options
443-
default_options = (self.RAW_DATA_CODEC_CONFIGS[codec].get(
444-
"options", {}).copy())
452+
options_dict = self.RAW_DATA_CODEC_CONFIGS[codec].get(
453+
"options", {})
454+
default_options = cast(Dict[str, Any], options_dict).copy()
445455
# Only merge raw-specific custom options
446456
default_options.update(self.raw_custom_options)
447457

@@ -451,7 +461,7 @@ def get_codec_options(self, codec: str) -> Dict[str, Any]:
451461
def for_transcoding_to_internal_codec(
452462
cls,
453463
internal_codec: str,
454-
codec_options: Optional[Dict[str, Any]] = None) -> "CodecConfig":
464+
codec_options: Optional[Dict[str, Any]] = None) -> Any:
455465
"""Create a CodecConfig specifically for transcoding to a particular internal codec.
456466
457467
This is used during transcoding operations where we need to convert between

robodm/backend/codecs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def get_container_encoding(self) -> str:
231231
class PyAVVideoCodec(VideoCodec):
232232
"""PyAV-based video codec wrapper"""
233233

234-
def __init__(self, codec_name: str = None, **kwargs):
234+
def __init__(self, codec_name: Optional[str] = None, **kwargs):
235235
# Handle both old and new initialization styles
236236
if codec_name is None:
237237
# New style: codec name should be passed as kwarg or inferred from registration

0 commit comments

Comments
 (0)