Skip to content

Commit

Permalink
🧑‍💻 Replace randint with id to remove non-determinism
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav-Kumbhat <[email protected]>
  • Loading branch information
gkumbhat committed Aug 12, 2022
1 parent 3d203e0 commit e94db07
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions import_tracker/lazy_import_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# Standard
from contextlib import AbstractContextManager
from functools import partial
from random import randint
from types import ModuleType
from typing import Callable, Optional, Set
import importlib.abc
Expand Down Expand Up @@ -91,7 +90,6 @@ def _make_extras_import_error(

# Look through frames in the stack to see if there's an extras module
extras_module = None

for frame in inspect.stack():
frame_module = frame.frame.f_globals["__name__"]
if frame_module in extras_modules:
Expand Down Expand Up @@ -259,7 +257,7 @@ def __ge__(self, *_, **__):
def __get__(self, *_, **__):
self._raise()

def __getitem__(self, *args, **kwargs):
def __getitem__(self, *_, **__):
self._raise()

def __gt__(self, *_, **__):
Expand All @@ -268,7 +266,7 @@ def __gt__(self, *_, **__):
def __hash__(self, *_, **__):
if not _is_import_time():
self._raise()
return randint(0, 100000000)
return id(self)

def __iadd__(self, *_, **__):
self._raise()
Expand Down

0 comments on commit e94db07

Please sign in to comment.