Skip to content

Commit 45c0ff3

Browse files
fix(decoration): cast mode.device to str for mypy return-value check
CI mypy (stricter torch stubs) catches that mode.device returns torch.device, not str. Explicit str() cast satisfies the Optional[str] return type annotation.
1 parent b5da8b8 commit 45c0ff3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

torchlens/decoration/torch_funcs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def _get_active_device() -> Optional[str]:
109109

110110
for mode in reversed(_get_current_function_mode_stack()):
111111
if isinstance(mode, _DeviceContext):
112-
return mode.device
112+
return str(mode.device)
113113
except (ImportError, AttributeError):
114114
pass
115115
return None

0 commit comments

Comments
 (0)