mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-17 17:42:20 +03:00
Added type checker hint for unbound names
Due to the fact that cmdr and entry are only assigned if item exists, a situation can arise where any access to the names will raise an UnboundLocalException, this tells the type checker to ignore that possibility by using a TYPE_CHECKING guarded assignment to those names. This does not fix the issue at runtime, it just tells the type checker that its fine. As this remains a bug, I have left TODOs in to note its existence.
This commit is contained in:
parent
7ab697a807
commit
62f3203c3f
@ -468,13 +468,14 @@ def worker() -> None:
|
||||
retrying = 0
|
||||
while retrying < 3:
|
||||
try:
|
||||
# TODO: Technically entry can be unbound here.
|
||||
if item and entry['event'] in ('CarrierJump', 'FSDJump', 'Location', 'Docked'):
|
||||
logger.debug(f'{entry["event"]}')
|
||||
if TYPE_CHECKING:
|
||||
# Tell the type checker that these two are bound.
|
||||
# TODO: While this works because of the item check below, these names are still technically unbound
|
||||
# TODO: in some cases, therefore this should be refactored.
|
||||
cmdr: str = ""
|
||||
entry: Mapping[str, Any] = {}
|
||||
|
||||
if item and entry['event'] not in this.discardedEvents:
|
||||
if entry['event'] in ('CarrierJump', 'FSDJump', 'Location', 'Docked'):
|
||||
logger.debug(f'{entry["event"]} event not in discarded list')
|
||||
if item and entry['event'] not in this.discardedEvents: # TODO: Technically entry can be unbound here.
|
||||
pending.append(entry)
|
||||
|
||||
# Get list of events to discard
|
||||
|
Loading…
x
Reference in New Issue
Block a user