You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "/work/generalimport/example.py", line 6, in <module>
class SubClass(test_module.BaseClass):
File "/work/generalimport/generalimport/fake_module.py", line 21, in error_func
raise MissingOptionalDependency(f"Optional dependency {name} was used but it isn't installed.")
generalimport.exception.MissingOptionalDependency: Optional dependency 'test_module' was used but it isn't installed.
This is quite limiting in OOP and makes using generalimport with libraries like sqlalchemy close to impossible.
Proposed solution
I propose leveraging __mro_entries__ to make this usecase work. Classes based on non-existing modules should fail only when initialized.
PR coming soon 🙂
The text was updated successfully, but these errors were encountered:
This is a really good idea, I haven't thought of this! I noticed that __init_subclass__ = error_func is the only method preventing subclassing currently.
I've never heard of __mro_entries__ before, never found it when I did my initial dunder research!
Problem
So far
generalimport
does not allow users to create subclasses of missing dependencies. So this code:fails with:
This is quite limiting in OOP and makes using
generalimport
with libraries likesqlalchemy
close to impossible.Proposed solution
I propose leveraging
__mro_entries__
to make this usecase work. Classes based on non-existing modules should fail only when initialized.PR coming soon 🙂
The text was updated successfully, but these errors were encountered: