diff --git a/EDMC.py b/EDMC.py index 4c5283a7..4120fd35 100755 --- a/EDMC.py +++ b/EDMC.py @@ -19,9 +19,8 @@ os.environ["EDMC_NO_UI"] = "1" # See EDMCLogging.py docs. # workaround for https://github.com/EDCD/EDMarketConnector/issues/568 from EDMCLogging import edmclogger, logger, logging - if TYPE_CHECKING: - from logging import trace, TRACE # type: ignore # noqa: F401 + from logging import TRACE # type: ignore # noqa: F401 # needed to make mypy happy edmclogger.set_channels_loglevel(logging.INFO) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index ed4f829c..f6e17e87 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -262,10 +262,10 @@ if __name__ == '__main__': # noqa: C901 # See EDMCLogging.py docs. # isort: off if TYPE_CHECKING: - from logging import trace, TRACE # type: ignore # noqa: F401 - import update + from logging import TRACE # type: ignore # noqa: F401 # Needed to update mypy + # import update # from infi.systray import SysTrayIcon -# isort: on + # isort: on def _(x: str) -> str: """Fake the l10n translation functions for typing.""" diff --git a/companion.py b/companion.py index fd56a4de..d374f169 100644 --- a/companion.py +++ b/companion.py @@ -19,8 +19,6 @@ import urllib.parse import webbrowser from builtins import object, range, str from email.utils import parsedate -# TODO: see https://github.com/EDCD/EDMarketConnector/issues/569 -from http.cookiejar import LWPCookieJar # noqa: F401 - No longer needed but retained in case plugins use it from os.path import join from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, OrderedDict, TypeVar, Union diff --git a/plug.py b/plug.py index eea96ea7..af4a50ac 100644 --- a/plug.py +++ b/plug.py @@ -1,21 +1,18 @@ """ Plugin hooks for EDMC - Ian Norton, Jonathan Harris """ -from builtins import str -from builtins import object -import os import importlib -import sys +import logging import operator -import threading # noqa: F401 - We don't use it, but plugins might -from typing import Optional +import os +import sys import tkinter as tk +from builtins import object, str +from typing import Optional import myNotebook as nb # noqa: N813 - -from config import appcmdname, appname, config +from config import config from EDMCLogging import get_main_logger -import logging logger = get_main_logger() @@ -140,7 +137,7 @@ def load_plugins(master): found = [] # Load any plugins that are also packages first 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())): + 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 ['.', '_']: pass elif name.endswith('.disabled'): @@ -172,6 +169,7 @@ def provides(fn_name): """ return [p.name for p in PLUGINS if p._get_func(fn_name)] + def invoke(plugin_name, fallback, fn_name, *args): """ Invoke a function on a named plugin @@ -187,7 +185,7 @@ def invoke(plugin_name, fallback, fn_name, *args): return plugin._get_func(fn_name)(*args) for plugin in PLUGINS: if plugin.name == fallback: - assert plugin._get_func(fn_name), plugin.name # fallback plugin should provide the function + assert plugin._get_func(fn_name), plugin.name # fallback plugin should provide the function return plugin._get_func(fn_name)(*args) diff --git a/plugins/edsm.py b/plugins/edsm.py index 422d0b56..7905f657 100644 --- a/plugins/edsm.py +++ b/plugins/edsm.py @@ -9,19 +9,19 @@ # 4) Ensure the EDSM API call(back) for setting the image at end of system # text is always fired. i.e. CAPI cmdr_data() processing. -from companion import CAPIData import json import sys import tkinter as tk from queue import Queue from threading import Thread -from typing import TYPE_CHECKING, Any, List, Mapping, MutableMapping, Optional, Tuple, cast +from typing import TYPE_CHECKING, Any, List, Mapping, MutableMapping, Optional, Tuple import requests import killswitch import myNotebook as nb # noqa: N813 import plug +from companion import CAPIData from config import applongname, appversion, config from EDMCLogging import get_main_logger from ttkHyperlinkLabel import HyperlinkLabel @@ -629,11 +629,11 @@ def worker() -> None: else: if msg_num // 100 == 1: - # logger.trace('Overall OK') + # logger.trace('Overall OK') pass elif msg_num // 100 == 5: - # logger.trace('Event(s) not currently processed, but saved for later') + # logger.trace('Event(s) not currently processed, but saved for later') pass else: diff --git a/setup.py b/setup.py index 372b4477..98a3ba4f 100755 --- a/setup.py +++ b/setup.py @@ -191,6 +191,8 @@ elif sys.platform == 'win32': 'shutil', # Included for plugins 'timeout_session', 'zipfile', # Included for plugins + 'threading', # Included for plugins (though it should always be there anyway) + 'http', # Included for plugins ], 'excludes': [ 'distutils', diff --git a/td.py b/td.py index 5f05b732..2f91b4a2 100644 --- a/td.py +++ b/td.py @@ -1,13 +1,11 @@ # Export to Trade Dangerous -from os.path import join +import time from collections import defaultdict -import codecs -import numbers from operator import itemgetter +from os.path import join from platform import system from sys import platform -import time from config import applongname, appversion, config diff --git a/theme.py b/theme.py index d05a52e6..702edf3c 100644 --- a/theme.py +++ b/theme.py @@ -12,14 +12,14 @@ from sys import platform from tkinter import font as tkFont from tkinter import ttk -from config import applongname, appname, config +from config import config from ttkHyperlinkLabel import HyperlinkLabel if __debug__: from traceback import print_exc if platform == "linux": - from ctypes import POINTER, c_char_p, c_int, c_long, c_uint, c_ulong, c_void_p, cdll, Structure, byref + from ctypes import POINTER, Structure, byref, c_char_p, c_int, c_long, c_uint, c_ulong, c_void_p, cdll if platform == 'win32':