1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-14 03:30:02 +00:00

trezor.utils: fix for mypy, remove genfunc

This commit is contained in:
Jan Pochyla 2017-06-14 19:34:23 +02:00
parent f5b5e399e5
commit 5b9ef8813a

View File

@ -3,8 +3,10 @@ import gc
from trezorutils import halt, memcpy
type_gen = type((lambda: (yield))())
type_genfunc = type((lambda: (yield)))
def _gf():
yield
type_gen = type(_gf())
def _unimport_func(func):
@ -21,7 +23,7 @@ def _unimport_func(func):
return inner
def _unimport_genfunc(genfunc):
def _unimport_gen(genfunc):
async def inner(*args, **kwargs):
mods = set(sys.modules)
try:
@ -36,15 +38,15 @@ def _unimport_genfunc(genfunc):
def unimport(func):
if isinstance(func, type_genfunc):
return _unimport_genfunc(func)
if isinstance(func, type_gen):
return _unimport_gen(func)
else:
return _unimport_func(func)
def chunks(l, n):
for i in range(0, len(l), n):
yield l[i:i + n]
def chunks(items, size):
for i in range(0, len(items), size):
yield items[i:i + size]
def ensure(cond):