core.cachew: make disabled_cachew defensive

This commit is contained in:
Dima Gerasimov 2020-09-18 20:53:27 +01:00 committed by karlicoss
parent ef72ac3386
commit e34c04ebc8
2 changed files with 7 additions and 1 deletions

View file

@ -20,7 +20,12 @@ def disable_cachew():
@contextmanager @contextmanager
def disabled_cachew(): def disabled_cachew():
import cachew try:
import cachew
except ModuleNotFoundError:
# no need to disable anything
yield
return
old = disable_cachew() old = disable_cachew()
try: try:
yield yield

View file

@ -202,6 +202,7 @@ if TYPE_CHECKING:
mcachew: McachewType mcachew: McachewType
# TODO ugh. I think it needs doublewrap, otherwise @mcachew without args doesn't work
def mcachew(*args, **kwargs): # type: ignore[no-redef] def mcachew(*args, **kwargs): # type: ignore[no-redef]
""" """
Stands for 'Maybe cachew'. Stands for 'Maybe cachew'.