Skip to content
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

wxGUI: Fix SIM115: Use context managers for file operations in image2target module #5404

Closed
wants to merge 4 commits into from

Conversation

arohanajit
Copy link
Contributor

Replace direct open() calls with context managers (with statements) in ii2t_manager.py for proper file handling with automatic closing even when exceptions occur. Improved by replacing open/read pattern with Path.read_text() to fix FURB101 warning. Also removed ruff code warnings

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@github-actions github-actions bot added GUI wxGUI related Python Related code is in Python labels Mar 17, 2025
Comment on lines 164 to 165
finally:
f.close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should happen if the try fails? Is the rest of the function / callers working correctly if it silently fails?

Comment on lines 362 to 363
finally:
f.close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing. Also, after getting out of a context manager, is f.close() still valid ? Does it error out? Is there a way for you to try one of it manually when running the gui?

Comment on lines 1232 to 1234
# pylint: disable=C2801
# ruff: noqa: PLC2801
ColumnSorterMixin.__init__(self, ncols)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems for your other PR, where I'm not sure it works as intended for a next line. Teach me and show me if I'm wrong

Comment on lines 2054 to 2055
finally:
f.close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same interrogation here

arohanajit and others added 2 commits March 18, 2025 12:01
@arohanajit arohanajit closed this Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI wxGUI related Python Related code is in Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants