feat(checkSyntax): create checkSyntaxStdin#318
Conversation
StantonMatt
left a comment
There was a problem hiding this comment.
I checked this against #295 locally.
Validation passed:
npm run compileOncenpx mocha -r ts-node/register test/test-python-shell.ts --grep "checkSyntaxStdin"npm testnpx prettier --check index.ts test/test-python-shell.tsgit diff --check origin/master...HEAD
No upstream checks are reported on this PR branch.
The behavior looks useful: the stdin path avoids creating pythonShellSyntaxCheck*.py temp files and the tests cover valid/invalid single-line and multiline syntax.
One thing I would tighten before merge: the test named should use pythonOptions from defaultOptions does not currently prove or implement that behavior. checkSyntaxStdin() builds the spawned argv as ["-c", "import sys; compile(...)"] and does not include defaultOptions.pythonOptions. I confirmed that with PythonShell.defaultOptions = { pythonOptions: ["--definitely-not-a-python-option"] }; checkSyntaxStdin("x=1") still passes because the option is ignored.
If option support is intended for this helper, it should include defaultOptions.pythonOptions in the spawned argv and test with a sentinel option that would fail if ignored. If not, I would rename or remove that test so the new API expectation stays clear.
resolve #295