Allow subprocess constants (e.g. DEVNULL) for stdio errlog parameter#2420
Open
SamSi0322 wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
Allow subprocess constants (e.g. DEVNULL) for stdio errlog parameter#2420SamSi0322 wants to merge 1 commit intomodelcontextprotocol:mainfrom
SamSi0322 wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
Widen the `errlog` type on `stdio_client()` and the platform process helpers from `TextIO` to `TextIO | int` so callers can pass `subprocess.DEVNULL`, `subprocess.PIPE`, or other integer constants accepted by `subprocess.Popen` and `anyio.open_process`. Previously, passing `subprocess.DEVNULL` required a type: ignore or a custom wrapper. The underlying process APIs already support int values for stderr — this change surfaces that capability in the public signature. Github-Issue: modelcontextprotocol#1806 Reported-by: Seyed Sajad Kahani
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Widens the
errlogparameter type onstdio_client()and the platform-specific process helpers to acceptintin addition toTextIO. This allows callers to passsubprocess.DEVNULL,subprocess.PIPE, or other integer file descriptor constants thatsubprocess.Popenandanyio.open_processalready support.Previously, suppressing stderr from a child process required a
type: ignorecomment or wrappingsubprocess.DEVNULL— even though the underlying APIs already accept it.Changes
stdio_client():errlog: TextIO→errlog: TextIO | int_create_platform_compatible_process(): samecreate_windows_process():errlog: TextIO | None→errlog: TextIO | int | None_create_windows_fallback_process(): sametest_stdio_client_devnull_errlogregression testTest plan
errlog=subprocess.DEVNULL, verifies it starts and communicates correctly via stdin/stdoutsys.stderrbehavior unchanged)Closes #1806