-
Notifications
You must be signed in to change notification settings - Fork 0
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
24g Improvements: Pseudo #71
Conversation
The Result TypedDictMost obvious thing that needs fixing here is that the pseudo-9608/pseudocode/__init__.py Lines 15 to 19 in b015209
And add the type annotation at instantiation: pseudo-9608/pseudocode/__init__.py Lines 62 to 68 in 26bb723
Registering handlersAnother type issue: we can't add new handlers to a Mapping; `mypy expects only MutableMappings to be changed. So let's update the type annotation: pseudo-9608/pseudocode/__init__.py Lines 45 to 51 in b015209
|
And we are done! No type errors! BugfixingDoesn't mean our code works yet. Let's do a simple test:
Result:
Allow NameExpr in array indexOops, our parser only handles literal indices. Simple fix really: [836e982]
Oops, we can never exit from |
Hmm ... seems like declaring variables is broken. This starts from the parser, which we did not completely fix to handle Names correctly: [62ee887] Along the way we add a Since Names have attached tokens, Declare does not need to be declared with a token anymore, and so we can pass a Name to Declare at instantiation: [e6a0f8b] Then we fix the handling of Declare.name: [9ff44e4] |
With some tracing, we find out it is happening in
Ah ... we didn't handle UnresolvedNames in index Exprs: [0ef9a21] |
Silly, really ... we didn't handle the Now we get stuck in a seemingly infinite loop; turns out we parsed FOR loops as Loops instead of Whiles, so they don't get picked up by And then fix |
One last fix; we need to ignore TypeStmts in the interpreter as well: [a3cf903]
There we go! |
Type fixing
|
We have working code (so far), and no type errors! |
Let's start by ignoring type errors that we can't/won't fix: [7c634ee], [7819c64]
This isn't closing an eye; it's making sure the "noise" doesn't distract us from more important type errors in future. Anyway, these issues can only be resolved with a python/mypy version upgrade, so we'll come back to them when that happens.