Skip to content

Commit d54edff

Browse files
fix(ray): Guard against module shadowing (#5254)
Use explicit imports to prevent `AttributeError` when `ray` is shadowed. Follows up on #5140.
1 parent fa7b1fe commit d54edff

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

sentry_sdk/integrations/ray.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
try:
1818
import ray # type: ignore[import-not-found]
19+
from ray import remote
1920
except ImportError:
2021
raise DidNotEnable("Ray not installed.")
2122

@@ -57,7 +58,7 @@ def _insert_sentry_tracing_in_signature(func: "Callable[..., Any]") -> None:
5758

5859

5960
def _patch_ray_remote() -> None:
60-
old_remote = ray.remote
61+
old_remote = remote
6162

6263
@functools.wraps(old_remote)
6364
def new_remote(

tests/test_shadowed_module.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def pytest_generate_tests(metafunc):
3030
submodule_names
3131
- {
3232
"litellm",
33-
"ray",
3433
},
3534
)
3635

0 commit comments

Comments
 (0)