-
Notifications
You must be signed in to change notification settings - Fork 124
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
Deriving all custom error from Exception and related #2671
Conversation
Thanks for opening a Pull Request. If you want to perform a review write a comment saying: @ansys-reviewer-bot review |
Here it goes: https://github.com/ansys/pymapdl/actions/runs/7544725242/job/20538709809?pr=2671#step:3:58
|
Typically I wouldn't worry about the diamond inheritance if all you're doing is inheriting from "empty" classes for the purposes of enabling an However, I also found this: https://docs.python.org/3/library/exceptions.html#inheriting-from-built-in-exceptions
I'm not entirely sure if this guidance applies here. As the class MapdlExceptionMixin:
"""Mixin class to mark an exception type as originating from MAPDL""" which would avoid inheriting from the built-in exceptions twice. [1] remove the base
|
I think that might've worked if
|
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #2671 +/- ##
==========================================
- Coverage 84.81% 82.86% -1.96%
==========================================
Files 47 47
Lines 9313 9319 +6
==========================================
- Hits 7899 7722 -177
- Misses 1414 1597 +183 |
this one was an easy one because
|
I'm also in the opinion on going ahead because as you mention the classes are not really complex and they are only for catching in Thank you a lot for your review @greschd !!
|
Interesting read: http://python-history.blogspot.com/2010/06/method-resolution-order.html
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I'm not very convinced on this one...
The idea is to have all the MAPDL error classes deriving from one (
MapdlException
), so we can do something like:With the current implementation, you can do this too:
I think it could add value, but it does generate maybe complicated inheritance relationships:
Because
MapdlValueError
inheritates fromValueError
(which inheritates fromException
) and fromMapdlException
(which inheritates fromException
).This creates a "diamond" which is not recommended diamond problem
Surely this classes are simple, and we are only overwritting
__init__
method... if anything, we can always go back?Related (but not much) #2653
Pinging @ansys/pyansys-core for technical feedback. Also pinging @koubaa @greschd