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

Allow Reader/Writer to be context managers #311

Merged
merged 2 commits into from
Sep 16, 2024

Conversation

esrice
Copy link
Contributor

@esrice esrice commented Sep 13, 2024

By adding __enter__ and __exit__ methods to the Reader and Writer classes, they can now be used as context managers. Also added a test to make sure the Reader context manager works correctly. Did not add a test to do the same with Writer, because trying to write to a closed Writer results in a segfault rather than raising an exception that can be checked by pytest.

By adding __enter__ and __exit__ methods to the Reader and Writer
classes, they can now be used as context managers. Also added a test to
make sure the Reader context manager works correctly. Did not add a test
to do the same with Writer, because trying to write to a closed Writer
results in a segfault rather than raising an exception that can be
checked by pytest.
Copy link
Owner

@brentp brentp left a comment

Choose a reason for hiding this comment

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

Looks good. You can remove the methods from Writer because Writer inherits from VCF.

not necessary because they will be inherited
@esrice
Copy link
Contributor Author

esrice commented Sep 13, 2024

Sounds good, how's this most recent commit?

@esrice esrice requested a review from brentp September 13, 2024 16:30
@brentp brentp merged commit 541ab16 into brentp:main Sep 16, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants