Replace is_read_log with read_log_when_error in stata_do#65
Merged
SepineTam merged 1 commit intodev/1.16.0from Apr 18, 2026
Merged
Replace is_read_log with read_log_when_error in stata_do#65SepineTam merged 1 commit intodev/1.16.0from
SepineTam merged 1 commit intodev/1.16.0from
Conversation
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.
Motivation
stata_dobehavior to avoid reading full logs by default and only read text logs when checking for Stata return-code errors (patternr(\d+)).is_read_logparameter fromstata_helpand update callers and CLI wiring to match the new API.Description
src/stata_mcp/api/stata_do.pyto replace theis_read_logparameter withread_log_when_error: bool = False, added conditional log-reading logic, and introduced the helper_has_stata_error(content: str) -> boolusingre.search(r"r\(\d+\)", ...)to detect Stata return-code errors.src/stata_mcp/api/ado_install.pyto callstata_do(..., read_log_when_error=False)when invoking the non-Unix installation flow.is_read_logparameter fromsrc/stata_mcp/api/stata_help.pyand simplified its local unused-variable handling.src/stata_mcp/mcp_servers.pyto expose the MCP tool withread_log_when_errorin thestata_dosignature, addedimport re, inserted_has_stata_errorhelper, and updated docs/tool description to reflect the new semantics.src/stata_mcp/cli/_handlers.pyso thedotool maps the existing CLI--is-read-logflag to the newread_log_when_errorargument and removed the obsoleteis_read_logpass-through forhelp.Testing
PYTHONPATH=src pytest -q, which completed successfully (10 tests passed).python -m compileall src/stata_mcp/api/stata_do.py src/stata_mcp/api/ado_install.py src/stata_mcp/api/stata_help.py src/stata_mcp/mcp_servers.py src/stata_mcp/cli/_handlers.py, which succeeded without errors.pytest -qrun withoutPYTHONPATH=srcfails in this environment due to import path setup, but the tests pass whensrcis added toPYTHONPATH.Codex Task