Skip to content

fix: add flush method to BytesIO#7235

Merged
youknowone merged 1 commit intoRustPython:mainfrom
ever0de:fix/add-flush-method-to-bytesio
Feb 27, 2026
Merged

fix: add flush method to BytesIO#7235
youknowone merged 1 commit intoRustPython:mainfrom
ever0de:fix/add-flush-method-to-bytesio

Conversation

@ever0de
Copy link
Copy Markdown
Contributor

@ever0de ever0de commented Feb 27, 2026

Summary by CodeRabbit

  • New Features

    • BytesIO class now includes a flush() method for improved stream management, providing proper error handling for closed streams.
  • Tests

    • Added test coverage for the new BytesIO.flush() method, validating behavior on both open and closed streams.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4c25370 and 0d85e0f.

📒 Files selected for processing (2)
  • crates/vm/src/stdlib/io.rs
  • extra_tests/snippets/stdlib_io_bytesio.py

📝 Walkthrough

Walkthrough

Added a flush() method to the BytesIO class that validates the stream is open and returns an error if closed. Includes test coverage verifying the method returns None when open and raises ValueError when the buffer is closed.

Changes

Cohort / File(s) Summary
BytesIO flush implementation
crates/vm/src/stdlib/io.rs
Added public flush() method to BytesIO class that returns Ok(()) on open streams and io_closed_error on closed streams.
BytesIO flush testing
extra_tests/snippets/stdlib_io_bytesio.py
Added test_07() function to verify flush() behavior: confirms method returns None when open, raises ValueError after stream closure.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rabbit hops with glee,
A flush for BytesIO, you see!
Close the stream and watch it fail,
Open wide—no need to wail.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: adding a flush method to the BytesIO class.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@youknowone youknowone merged commit 09cf492 into RustPython:main Feb 27, 2026
13 checks passed
youknowone pushed a commit to youknowone/RustPython that referenced this pull request Mar 22, 2026
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