1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-25 17:09:44 +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 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): def _unimport_func(func):
@ -21,7 +23,7 @@ def _unimport_func(func):
return inner return inner
def _unimport_genfunc(genfunc): def _unimport_gen(genfunc):
async def inner(*args, **kwargs): async def inner(*args, **kwargs):
mods = set(sys.modules) mods = set(sys.modules)
try: try:
@ -36,15 +38,15 @@ def _unimport_genfunc(genfunc):
def unimport(func): def unimport(func):
if isinstance(func, type_genfunc): if isinstance(func, type_gen):
return _unimport_genfunc(func) return _unimport_gen(func)
else: else:
return _unimport_func(func) return _unimport_func(func)
def chunks(l, n): def chunks(items, size):
for i in range(0, len(l), n): for i in range(0, len(items), size):
yield l[i:i + n] yield items[i:i + size]
def ensure(cond): def ensure(cond):