-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Reduce code duplication #5278
Reduce code duplication #5278
Conversation
Closed and reopened pull request to trigger CI rebuild |
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.
Thank you for your pull request. I just had a couple comments.
try: | ||
fileobj = open_file(path, text, encoding, log, **kwargs) |
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.
To preserve the original integrity, this should occur prior to the try
block, otherwise you need to protect the fileobj.close()
call since fileobj
will be None
if open_file()
throws an exception.
|
||
try: | ||
fileobj = open_file(path, text, encoding, log, **kwargs) |
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.
Same comment as above regarding fileobj
being None
in exception block.
Passed to :func:`io.open`.""" | ||
|
||
if os.path.islink(path): | ||
path = os.path.join(os.path.dirname(path), os.readlink(path)) |
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.
This if
block shouldn't be part of the reduction since this same code exists in atomic_writting()
with dependent code in between.
Closing as the maintained server code now lives in the Jupyter Server repo: https://github.com/jupyter-server/jupyter_server @mikebeijen please open a PR in https://github.com/jupyter-server/jupyter_server if you think this change is still applicable. Thanks! |
Removes duplicated code