I'm not that fluent in Python so I'm not sure if what I'm doing is common practice or the proper way to do it.
I'm creating a module archive
contaning files with one class each, e.g. SmsArchiveReader.py
with class SmsArchiveReader
inside. To make the imports less tedious, I decided to import the classes directly into the __init__.py
.
However, both Spyder and Pylint have issues with my __init__.py
, with Spyder telling me that I shouldn't have unused imports, and Pylint telling me that I shouldn't use absolute imports. Both suggestions seem pointless to me, since this is __init__.py
we're talking about, but I'm open to suggestions.
Image below:
As for the look I wanted to achieve, I wanted the code using this module to look like that:
import archive
myReader = archive.SmsArchiveReader()
myReader2 = archive.FooArchiveReader()
instead of:
import archive
myReader = archive.SmsArchiveReader.SmsArchiveReader()
myReader2 = archive.FooArchiveReader.FooArchiveReader()
So what's the correct practice of creating modules?
As jonrsharpe said, it's a problem with Spyder IDE. This issue has been submitted to their bug tracker, the interested can follow its status on Github.