From b469519e2679ed3c6153a50de7afa84b5b4d12d7 Mon Sep 17 00:00:00 2001 From: Saleem Rashid Date: Mon, 31 Jul 2017 12:35:31 +0100 Subject: [PATCH] client: fix matrix recovery, use named enums, use isdigit(), ignore broken E721 test --- .flake8 | 4 +++- trezorlib/client.py | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.flake8 b/.flake8 index c1e384089..f70b8f427 100644 --- a/.flake8 +++ b/.flake8 @@ -19,4 +19,6 @@ ignore = # E402: module level import not at top of file E402, # E501: line too long - E501 + E501, + # E721: do not compare types, use 'isinstance()' + E721 diff --git a/trezorlib/client.py b/trezorlib/client.py index aeea30847..eb9923176 100644 --- a/trezorlib/client.py +++ b/trezorlib/client.py @@ -254,18 +254,18 @@ class TextUIMixin(object): return proto.WordAck(word='\x08') # ignore middle column if only 6 keys requested. - if (isinstance(msg.type, types.WordRequestType_Matrix6) and character in ('2', '5', '8')): + if msg.type == types.WordRequestType_Matrix6 and character in ('2', '5', '8'): continue - if (ord(character) >= ord('1') and ord(character) <= ord('9')): + if character.isdigit(): return proto.WordAck(word=character) def callback_PinMatrixRequest(self, msg): - if msg.type == 1: + if msg.type == types.PinMatrixRequestType_Current: desc = 'current PIN' - elif msg.type == 2: + elif msg.type == types.PinMatrixRequestType_NewFirst: desc = 'new PIN' - elif msg.type == 3: + elif msg.type == types.PinMatrixRequestType_NewSecond: desc = 'new PIN again' else: desc = 'PIN'