xbmc/addon-check

refactor suggests invalid code

Closed this issue · 2 comments

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.

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

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