-
Notifications
You must be signed in to change notification settings - Fork 192
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
Implement next
and iter
for the Node.open
deprecation wrapper
#4399
Implement next
and iter
for the Node.open
deprecation wrapper
#4399
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #4399 +/- ##
===========================================
+ Coverage 79.22% 79.22% +0.01%
===========================================
Files 475 475
Lines 34822 34826 +4
===========================================
+ Hits 27583 27588 +5
+ Misses 7239 7238 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
Do we want a regression test for this?
The return value of `Node.open` was wrapped in `WarnWhenNotEntered` in `aiida-core==1.4.0` in order to warn users that use the method without a context manager, which will start to raise in v2.0. Unfortunately, the raising came a little early as the wrapper does not implement the `__iter__` and `__next__` methods, which can be called by clients. An example is `numpy.getfromtxt` which will notice the return value of `Node.open` is filelike and so will wrap it in `iter`. Without the current fix, this raises a `TypeError`. The proper fix would be to forward all magic methods to the wrapped filelike object, but it is not clear how to do this.
378a3f9
to
1b97877
Compare
Done |
@greschd I added a test, this is ready for second review |
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.
Thanks @sphuber !
…iidateam#4399) The return value of `Node.open` was wrapped in `WarnWhenNotEntered` in `aiida-core==1.4.0` in order to warn users that use the method without a context manager, which will start to raise in v2.0. Unfortunately, the raising came a little early as the wrapper does not implement the `__iter__` and `__next__` methods, which can be called by clients. An example is `numpy.getfromtxt` which will notice the return value of `Node.open` is filelike and so will wrap it in `iter`. Without the current fix, this raises a `TypeError`. The proper fix would be to forward all magic methods to the wrapped filelike object, but it is not clear how to do this.
Fixes #4396
The return value of
Node.open
was wrapped inWarnWhenNotEntered
inaiida-core==1.4.0
in order to warn users that use the method without acontext manager, which will start to raise in v2.0. Unfortunately, the
raising came a little early as the wrapper does not implement the
__iter__
and__next__
methods, which can be called by clients.An example is
numpy.genfromtxt
which will notice the return value ofNode.open
is filelike and so will wrap it initer
. Without thecurrent fix, this raises a
TypeError
. The proper fix would be toforward all magic methods to the wrapped filelike object, but it is not
clear how to do this.