-
Notifications
You must be signed in to change notification settings - Fork 21
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
Remove the target
keyword from rdm_open
#235
Remove the target
keyword from rdm_open
#235
Conversation
of the model. In this case the constructor should just directly return | ||
the model. | ||
""" | ||
if init.__class__.__name__ == cls.__name__: |
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.
Bad things happen (infinite recursion) if one tries to isinstance
checks here.
b722011
to
402c887
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #235 +/- ##
==========================================
+ Coverage 94.47% 95.00% +0.53%
==========================================
Files 23 23
Lines 1628 1621 -7
==========================================
+ Hits 1538 1540 +2
+ Misses 90 81 -9
☔ View full report in Codecov by Sentry. |
402c887
to
23d5233
Compare
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
23d5233
to
100e32e
Compare
Issue spacetelescope#51 and PR spacetelescope#52 indicate that we should be able to pass a model instance to a matching model's constructor, and then return exactly the same instance unmodified.
100e32e
to
e0bcccd
Compare
This PR addresses issue #51 and the partial solution to it in PR #52. The solution in #52 was to add the
target
keyword tordm_open
, however it did not fix the actual issue from #51. Then in PR #59, the tests for the solution in #52 were completely removed, and after that point thetarget
argument completely ceased being used inroman_datamodels
andromancal
.The issue at hand in #51 is that if we pass a data model instance to the datamodel constructor (
<data_model_class>(*args, **kwargs)
), then we don't want it to raise an error. The discussion and solution in #52 additionally indicates the we should pass the exact object out with no alterations rather than constructing a new object.This pull request adds a test reproducing the error described in #51 together with the additional constraints from #52. It then solves the issue via injecting a new
__new__
method for theDataModel
objects which detects and then handles this case special case. It then reverts the partial solution from #52.Checklist
CHANGES.rst
under the corresponding subsection