-
Notifications
You must be signed in to change notification settings - Fork 3
Check signature of returned Callable for ProgramSynthesisHander #421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging-llm
Are you sure you want to change the base?
Conversation
jfeser
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
@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) |
|
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 |
|
@jfeser I see, thanks! I think I got a better idea now. Let me try another iteration. |
Closes #361