xbmc / addon-check

Automatic checks for new repository submissions
GNU General Public License v3.0
52 stars 42 forks source link

refactor suggests invalid code #268

Closed ReenigneArcher closed 1 month ago

ReenigneArcher commented 10 months ago

This tool suggests refactoring my code as shown here.

INFO: ./service.themerr/service.py

--- ./service.themerr/service.py    (original)
+++ ./service.themerr/service.py    (refactored)
@@ -7,9 +7,9 @@
 import xbmcvfs

 # lib imports
-from themerr import constants
-from themerr.logger import Logger
-from themerr.settings import Settings
+from .themerr import constants
+from .themerr.logger import Logger
+from .themerr.settings import Settings

 settings = Settings()
 log = Logger()

But this suggestion is invalid. When the __name__ is __main__ you cannot do a relative import... and it seems that this is how Kodi runs the addon. https://stackoverflow.com/a/66895066/11214013

The relative imports work if you import the file into an existing python instance, but not when you run python ./service.py.

Is there anyway to skip the refactoring? It also causes a second problem if my dependencies are installed to the addon directory (./resources/lib)... there will thousands of warnings. Excluding specific directories would be beneficial.

ReenigneArcher commented 1 month ago

Closing as I archived my Kodi add-on today, and this has been open almost a year with no response.

razzeee commented 1 month ago

Please post a complete reproduction. It could be the python2to3 part, but I doubt that.