Check signature of returned Callable for ProgramSynthesisHander#421
Closed
datvo06 wants to merge 2 commits intostaging-llmfrom
Closed
Check signature of returned Callable for ProgramSynthesisHander#421datvo06 wants to merge 2 commits intostaging-llmfrom
datvo06 wants to merge 2 commits intostaging-llmfrom
Conversation
jfeser
requested changes
Dec 4, 2025
Contributor
Author
|
@jfeser Thanks! I see, so we directly do the static analysis. Is the expected solution somewhere along this line? import tempfile
from mypy import api
def _type_check_code(self, code: str, expected_type: type) -> None:
"""Run mypy on generated code to verify type correctness."""
# Write code to temp file for mypy
with tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False) as f:
f.write(code)
temp_path = f.name
try:
result = api.run([temp_path, '--no-error-summary', '--no-pretty'])
stdout, stderr, exit_code = result
if exit_code != 0:
raise SynthesisError(f"Type check failed:\n{stdout}", code)
finally:
import os
os.unlink(temp_path) |
Contributor
|
I suspect the hard part of #361 will be giving the type checker appropriate context so that it can check code that uses types not defined by the LLM. E.g. The type checker needs to see the definition of |
Contributor
Author
|
@jfeser I see, thanks! I think I got a better idea now. Let me try another iteration. |
Contributor
Author
Contributor
|
I think this may have been handled in #519 |
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.
Closes #361