From 75ee57939a0277a1111962d1f02992c8b020aca8 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Thu, 8 Dec 2022 11:32:41 +0000 Subject: [PATCH] EDMarketConnector: Force type of ship_state It can be `tk.NORMAL` or `tk.DISABLED`. Why `True` was ever used I don't know, possibly relying on undefined behaviour. However, those 'types' end up as `Literal['normal']` and `Literal['disabled']` and the only way to declare a Union of those is to be explicit with the actual strings. tk.(NORMAL|DISABLED) are not a types. --- EDMarketConnector.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index 64d0aee2..00cc5c4f 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -16,7 +16,7 @@ from builtins import object, str from os import chdir, environ from os.path import dirname, join from time import localtime, strftime, time -from typing import TYPE_CHECKING, Optional, Tuple, Union +from typing import TYPE_CHECKING, Literal, Optional, Tuple, Union # Have this as early as possible for people running EDMarketConnector.exe # from cmd.exe or a bat file or similar. Else they might not be in the correct @@ -1356,7 +1356,7 @@ class AppWindow(object): # Ensure the ship type/name text is clickable, if it should be. if monitor.state['Modules']: - ship_state = True + ship_state: Literal['normal', 'disabled'] = tk.NORMAL else: ship_state = tk.DISABLED