diff --git a/EDMarketConnector.py b/EDMarketConnector.py index 87ba6814..4b73f9f3 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -1547,7 +1547,7 @@ class AppWindow: self.w.update_idletasks() # Companion login - if entry['event'] in [None, 'StartUp', 'NewCommander', 'LoadGame'] and monitor.cmdr: + if entry['event'] in (None, 'StartUp', 'NewCommander', 'LoadGame') and monitor.cmdr: if not config.get_list('cmdrs') or monitor.cmdr not in config.get_list('cmdrs'): config.set('cmdrs', config.get_list('cmdrs', default=[]) + [monitor.cmdr]) self.login() @@ -1565,7 +1565,7 @@ class AppWindow: logger.trace_if('journal.queue', 'Startup, returning') return # Startup - if entry['event'] in ['StartUp', 'LoadGame'] and monitor.started: + if entry['event'] in ('StartUp', 'LoadGame') and monitor.started: logger.info('StartUp or LoadGame event') # Disable WinSparkle automatic update checks, IFF configured to do so when in-game diff --git a/hotkey/darwin.py b/hotkey/darwin.py index 63f9d132..6afd0239 100644 --- a/hotkey/darwin.py +++ b/hotkey/darwin.py @@ -211,12 +211,12 @@ class MacHotkeyMgr(AbstractHotkeyMgr): return False # BkSp, Del, Clear = clear hotkey - if keycode in [0x7f, ord(NSDeleteFunctionKey), ord(NSClearLineFunctionKey)]: + if keycode in (0x7f, ord(NSDeleteFunctionKey), ord(NSClearLineFunctionKey)): self.acquire_state = MacHotkeyMgr.ACQUIRE_INACTIVE return None # don't allow keys needed for typing in System Map - if keycode in [0x13, 0x20, 0x2d] or 0x61 <= keycode <= 0x7a: + if keycode in (0x13, 0x20, 0x2d) or 0x61 <= keycode <= 0x7a: NSBeep() self.acquire_state = MacHotkeyMgr.ACQUIRE_INACTIVE return None diff --git a/hotkey/windows.py b/hotkey/windows.py index f21a24b2..fa4cb3a6 100644 --- a/hotkey/windows.py +++ b/hotkey/windows.py @@ -284,23 +284,23 @@ class WindowsHotkeyMgr(AbstractHotkeyMgr): | ((GetKeyState(VK_RWIN) & 0x8000) and MOD_WIN) keycode = event.keycode - if keycode in [VK_SHIFT, VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN]: + if keycode in (VK_SHIFT, VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN): return 0, modifiers if not modifiers: if keycode == VK_ESCAPE: # Esc = retain previous return False - if keycode in [VK_BACK, VK_DELETE, VK_CLEAR, VK_OEM_CLEAR]: # BkSp, Del, Clear = clear hotkey + if keycode in (VK_BACK, VK_DELETE, VK_CLEAR, VK_OEM_CLEAR): # BkSp, Del, Clear = clear hotkey return None if ( - keycode in [VK_RETURN, VK_SPACE, VK_OEM_MINUS] or ord('A') <= keycode <= ord('Z') + keycode in (VK_RETURN, VK_SPACE, VK_OEM_MINUS) or ord('A') <= keycode <= ord('Z') ): # don't allow keys needed for typing in System Map winsound.MessageBeep() return None - if (keycode in [VK_NUMLOCK, VK_SCROLL, VK_PROCESSKEY] + if (keycode in (VK_NUMLOCK, VK_SCROLL, VK_PROCESSKEY) or VK_CAPITAL <= keycode <= VK_MODECHANGE): # ignore unmodified mode switch keys return 0, modifiers diff --git a/outfitting.py b/outfitting.py index 07e8ae76..3305929c 100644 --- a/outfitting.py +++ b/outfitting.py @@ -79,7 +79,7 @@ def lookup(module, ship_map, entitled=False) -> dict | None: # noqa: C901, CCR0 new['rating'] = 'I' # Skip uninteresting stuff - some no longer present in ED 3.1 cAPI data - elif (name[0] in [ + elif (name[0] in ( 'bobble', 'decal', 'nameplate', @@ -87,7 +87,7 @@ def lookup(module, ship_map, entitled=False) -> dict | None: # noqa: C901, CCR0 'enginecustomisation', 'voicepack', 'weaponcustomisation' - ] + ) or name[1].startswith('shipkit')): return None @@ -205,10 +205,10 @@ def lookup(module, ship_map, entitled=False) -> dict | None: # noqa: C901, CCR0 elif len(name) < 4 and name[1] == 'resourcesiphon': # Hack! 128066402 has no size or class. (new['class'], new['rating']) = ('1', 'I') - elif len(name) < 4 and name[1] in ['guardianpowerdistributor', 'guardianpowerplant']: # Hack! No class. + elif len(name) < 4 and name[1] in ('guardianpowerdistributor', 'guardianpowerplant'): # Hack! No class. (new['class'], new['rating']) = (str(name[2][4:]), 'A') - elif len(name) < 4 and name[1] in ['guardianfsdbooster']: # Hack! No class. + elif len(name) < 4 and name[1] == 'guardianfsdbooster': # Hack! No class. (new['class'], new['rating']) = (str(name[2][4:]), 'H') else: diff --git a/plug.py b/plug.py index aa34ce77..15e7cfaa 100644 --- a/plug.py +++ b/plug.py @@ -165,7 +165,7 @@ def load_plugins(master: tk.Tk) -> None: def _load_internal_plugins(): internal = [] for name in sorted(os.listdir(config.internal_plugin_dir_path)): - if name.endswith('.py') and name[0] not in ['.', '_']: + if name.endswith('.py') and name[0] not in ('.', '_'): try: plugin = Plugin(name[:-3], os.path.join(config.internal_plugin_dir_path, name), logger) plugin.folder = None @@ -184,7 +184,7 @@ def _load_found_plugins(): for name in sorted(os.listdir(config.plugin_dir_path), key=lambda n: ( not os.path.isfile(os.path.join(config.plugin_dir_path, n, '__init__.py')), n.lower())): - if not os.path.isdir(os.path.join(config.plugin_dir_path, name)) or name[0] in ['.', '_']: + if not os.path.isdir(os.path.join(config.plugin_dir_path, name)) or name[0] in ('.', '_'): pass elif name.endswith('.disabled'): name, discard = name.rsplit('.', 1) diff --git a/plugins/inara.py b/plugins/inara.py index 199e6a1c..d523bb2e 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -918,7 +918,7 @@ def journal_entry( # noqa: C901, CCR001 ]) # optional mission-specific properties - for (iprop, prop) in [ + for (iprop, prop) in ( ('missionExpiry', 'Expiry'), # Listed as optional in the docs, but always seems to be present ('starsystemNameTarget', 'DestinationSystem'), ('stationNameTarget', 'DestinationStation'), @@ -932,7 +932,7 @@ def journal_entry( # noqa: C901, CCR001 ('passengerCount', 'PassengerCount'), ('passengerIsVIP', 'PassengerVIPs'), ('passengerIsWanted', 'PassengerWanted'), - ]: + ): if prop in entry: data[iprop] = entry[prop] @@ -1295,7 +1295,7 @@ def journal_entry( # noqa: C901, CCR001 # Friends if event_name == 'Friends': - if entry['Status'] in ['Added', 'Online']: + if entry['Status'] in ('Added', 'Online'): new_add_event( 'addCommanderFriend', entry['timestamp'], @@ -1305,7 +1305,7 @@ def journal_entry( # noqa: C901, CCR001 } ) - elif entry['Status'] in ['Declined', 'Lost']: + elif entry['Status'] in ('Declined', 'Lost'): new_add_event( 'delCommanderFriend', entry['timestamp'], @@ -1666,7 +1666,7 @@ def handle_special_events(data_event: dict[str, Any], reply_event: dict[str, Any this.lastlocation = reply_event.get('eventData', {}) if not config.shutting_down: this.system_link.event_generate('<>', when="tail") - elif data_event['eventName'] in ['addCommanderShip', 'setCommanderShip']: + elif data_event['eventName'] in ('addCommanderShip', 'setCommanderShip'): this.lastship = reply_event.get('eventData', {}) if not config.shutting_down: this.system_link.event_generate('<>', when="tail") diff --git a/tests/config/_old_config.py b/tests/config/_old_config.py index 22f0b18f..690c75eb 100644 --- a/tests/config/_old_config.py +++ b/tests/config/_old_config.py @@ -296,7 +296,7 @@ class OldConfig: None, ctypes.byref(key_size) ) - or key_type.value not in [REG_SZ, REG_MULTI_SZ] + or key_type.value not in (REG_SZ, REG_MULTI_SZ) ): return default diff --git a/ttkHyperlinkLabel.py b/ttkHyperlinkLabel.py index 24470a93..d3858bad 100644 --- a/ttkHyperlinkLabel.py +++ b/ttkHyperlinkLabel.py @@ -80,10 +80,10 @@ class HyperlinkLabel(sys.platform == 'darwin' and tk.Label or ttk.Label): # typ ) -> dict[str, tuple[str, str, str, Any, Any]] | None: """Change cursor and appearance depending on state and text.""" # This class' state - for thing in ['url', 'popup_copy', 'underline']: + for thing in ('url', 'popup_copy', 'underline'): if thing in kw: setattr(self, thing, kw.pop(thing)) - for thing in ['foreground', 'disabledforeground']: + for thing in ('foreground', 'disabledforeground'): if thing in kw: setattr(self, thing, kw[thing])