-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
configuring all
modules: catching AttributeErrors on missing blocks?
#223
Comments
This would also benefit |
After changes from this PR If you directly with doctor it'll at least warn you to check the docs:
If you use it behind import_source, it warns you and continues:
If you add it to disabled modules, works without warning, as expected:
|
solved by #224 |
Something I've been thinking about for a while now -- currently in the process of splitting my mail module to have an
all.py
fileSo previously, there was no
class mbox
, it was the nested:So, the
all.py
imports from bothimap.py
and the newmbox.py
: https://github.com/seanbreckenridge/HPI/blob/ffbae2767b8c11e2b093b8cf28a941b0a8dfa4f6/my/mail/all.pyThen, when running the
my.mail.all
doctor, which imports from both:That imports like:
which is what causes the error - since the user doesnt have an
mbox
defined on theirclass mail
in their config.They may have not set it up yet, or they may just not want to use it
In the latter case, theres no way to configure this without modifying the
all.py
file and removing the source. That is a solution, but I think it would be nice to catch this AttributeError and send a warning to add the module to theirdisabled_modules
or something instead?That way it doesn't fatally error when they're using the
all.py
-- the so-called entrypoint to the whole moduleThis only happens when there are no additional dependencies for a module. If there were,
import_source
would correctly catch the import error and return the defaultI guess at the top of
mbox
could do:but feels not mypy friendly and pretty hacky
Can create a PR if catching the AttributeError sounds good -- would probably try and do regex to match it more specifically, to prevent catching unrelated errors
The text was updated successfully, but these errors were encountered: