pylint: apdu/ts_102_221.py

pySim/apdu/ts_102_221.py:60:16: R1724: Unnecessary "else" after "continue", remove the "else" and de-indent the code inside it (no-else-continue)
pySim/apdu/ts_102_221.py:107:16: W0107: Unnecessary pass statement (unnecessary-pass)
pySim/apdu/ts_102_221.py:294:8: R1703: The if statement can be replaced with 'return bool(test)' (simplifiable-if-statement)
pySim/apdu/ts_102_221.py:294:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
pySim/apdu/ts_102_221.py:299:31: W0613: Unused argument 'lchan' (unused-argument)
...
pySim/apdu/ts_102_221.py:389:8: R1705: Unnecessary "elif" after "return", remove the leading "el" from "elif" (no-else-return)
pySim/apdu/ts_102_221.py:421:8: R1705: Unnecessary "elif" after "return", remove the leading "el" from "elif" (no-else-return)
pySim/apdu/ts_102_221.py:425:12: R1705: Unnecessary "elif" after "return", remove the leading "el" from "elif" (no-else-return)
pySim/apdu/ts_102_221.py:438:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
pySim/apdu/ts_102_221.py:26:0: C0411: standard import "from typing import Optional, Dict, Tuple" should be placed before "from construct import GreedyRange, Struct" (wrong-import-order)

Change-Id: Id5caac8da4c965dbaf88d624cdc9dcc8fc168b8c
diff --git a/pySim/apdu/ts_102_221.py b/pySim/apdu/ts_102_221.py
index 48401c0..6e14b8a 100644
--- a/pySim/apdu/ts_102_221.py
+++ b/pySim/apdu/ts_102_221.py
@@ -17,13 +17,15 @@
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
 
+from typing import Optional, Dict
 import logging
+
 from construct import GreedyRange, Struct
+
 from pySim.construct import *
 from pySim.filesystem import *
 from pySim.runtime import RuntimeLchan
 from pySim.apdu import ApduCommand, ApduCommandSet
-from typing import Optional, Dict, Tuple
 
 logger = logging.getLogger(__name__)
 
@@ -104,7 +106,6 @@
                 #print("\tSELECT AID %s" % adf)
             else:
                 logger.warning('SELECT UNKNOWN AID %s', aid)
-                pass
         else:
             raise ValueError('Select Mode %s not implemented' % mode)
         # decode the SELECT response
@@ -291,12 +292,9 @@
 
     @staticmethod
     def _pin_is_success(sw):
-        if sw[0] == 0x63:
-            return True
-        else:
-            return False
+        return bool(sw[0] == 0x63)
 
-    def process_on_lchan(self, lchan: RuntimeLchan):
+    def process_on_lchan(self, _lchan: RuntimeLchan):
         return VerifyPin._pin_process(self)
 
     def _is_success(self):
@@ -308,7 +306,7 @@
     _apdu_case = 3
     _construct_p2 = PinConstructP2
 
-    def process_on_lchan(self, lchan: RuntimeLchan):
+    def process_on_lchan(self, _lchan: RuntimeLchan):
         return VerifyPin._pin_process(self)
 
     def _is_success(self):
@@ -320,7 +318,7 @@
     _apdu_case = 3
     _construct_p2 = PinConstructP2
 
-    def process_on_lchan(self, lchan: RuntimeLchan):
+    def process_on_lchan(self, _lchan: RuntimeLchan):
         return VerifyPin._pin_process(self)
 
     def _is_success(self):
@@ -331,7 +329,7 @@
 class EnablePin(ApduCommand, n='ENABLE PIN', ins=0x28, cla=['0X', '4X', '6X']):
     _apdu_case = 3
     _construct_p2 = PinConstructP2
-    def process_on_lchan(self, lchan: RuntimeLchan):
+    def process_on_lchan(self, _lchan: RuntimeLchan):
         return VerifyPin._pin_process(self)
 
     def _is_success(self):
@@ -343,7 +341,7 @@
     _apdu_case = 3
     _construct_p2 = PinConstructP2
 
-    def process_on_lchan(self, lchan: RuntimeLchan):
+    def process_on_lchan(self, _lchan: RuntimeLchan):
         return VerifyPin._pin_process(self)
 
     def _is_success(self):
@@ -396,13 +394,12 @@
             manage_channel.add_lchan(created_channel_nr)
             self.col_id = '%02u' % created_channel_nr
             return {'mode': mode, 'created_channel': created_channel_nr }
-        elif mode == 'close_channel':
+        if mode == 'close_channel':
             closed_channel_nr = self.cmd_dict['p2']['logical_channel_number']
             rs.del_lchan(closed_channel_nr)
             self.col_id = '%02u' % closed_channel_nr
             return {'mode': mode, 'closed_channel': closed_channel_nr }
-        else:
-            raise ValueError('Unsupported MANAGE CHANNEL P1=%02X' % self.p1)
+        raise ValueError('Unsupported MANAGE CHANNEL P1=%02X' % self.p1)
 
 # TS 102 221 Section 11.1.18
 class GetChallenge(ApduCommand, n='GET CHALLENGE', ins=0x84, cla=['0X', '4X', '6X']):
@@ -420,13 +417,13 @@
         p2 = hdr[3]
         if p1 & 0x7 == 0:   # retrieve UICC Endpoints
             return 2
-        elif p1 & 0xf in [1,2,3]:   # establish sa, start secure channel SA
+        if p1 & 0xf in [1,2,3]:   # establish sa, start secure channel SA
             p2_cmd = p2 >> 5
             if p2_cmd in [0,2,4]:   # command data
                 return 3
-            elif p2_cmd in [1,3,5]: # response data
+            if p2_cmd in [1,3,5]: # response data
                 return 2
-        elif p1 & 0xf == 4:         # terminate secure channel SA
+        if p1 & 0xf == 4:         # terminate secure channel SA
             return 3
         raise ValueError('%s: Unable to detect APDU case for %s' % (cls.__name__, b2h(hdr)))
 
@@ -437,8 +434,7 @@
         p1 = hdr[2]
         if p1 & 0x04:
             return 3
-        else:
-            return 2
+        return 2
 
 # TS 102 221 Section 11.1.22
 class SuspendUicc(ApduCommand, n='SUSPEND UICC', ins=0x76, cla=['80']):