Skip to content

Simplify subprocess communication in _runopenssl helper#1522

Merged
alex merged 1 commit into
mainfrom
claude/pyopenssl-mypy-failures-rjupr0
Jul 24, 2026
Merged

Simplify subprocess communication in _runopenssl helper#1522
alex merged 1 commit into
mainfrom
claude/pyopenssl-mypy-failures-rjupr0

Conversation

@reaperhulk

Copy link
Copy Markdown
Member

Summary

Refactored the _runopenssl helper function in the crypto tests to use subprocess.Popen.communicate() instead of manually managing stdin/stdout pipes.

Key Changes

  • Replaced manual pipe management (write, close, read, close, wait) with a single communicate() call
  • Removed unnecessary assertions checking that stdin/stdout are not None
  • Simplified the code from 7 lines to 1 line while maintaining identical functionality

Implementation Details

The communicate() method is the recommended way to interact with subprocesses as it:

  • Handles all pipe I/O automatically
  • Prevents deadlocks that can occur with manual pipe management
  • Automatically waits for process completion
  • Returns a tuple of (stdout, stderr) data

This change improves code clarity and follows subprocess best practices.

https://claude.ai/code/session_01FHw2uDgLcFsTfoStC4tzGv

Recent typeshed changed Popen.stdout from IO[AnyStr] to IO[Any], so
reading from it directly returns Any and trips no-any-return. Use
Popen.communicate(), which is still generically typed and does the
same write/close/read/wait dance.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FHw2uDgLcFsTfoStC4tzGv

@alex alex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lol, what motivated this?

@reaperhulk

Copy link
Copy Markdown
Member Author

mypy error 😄

@alex
alex merged commit 94ff658 into main Jul 24, 2026
75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants