-
-
Notifications
You must be signed in to change notification settings - Fork 130
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
Enaml syntaxerror detail #530
Enaml syntaxerror detail #530
Conversation
This does not actually capture the error I am attempting to fix.
I am surprised that GHA did not run. Also it looks like your change could break older Python since old syntax error probably won't handle well so many arguments. |
I tested down to 3.8 and it did not break. I think SyntaxError was designed to accept |
I see the tests are failing. It's possible I did not test correctly. I think we can just add a check for |
FYI, |
This also fixes a bug in the unit test (the assert statement was missing).
What error do you see ? I have not seen such issues but I usually regenerate the parser using the full path to the script, not sure it should make a difference. |
So, when I
However, I just created a fresh environment to test |
Ok. That last commit finally showed up here and the CI checks seem to have passed successfully for all Python versions. I'm working on another computer and ran into this exact same issue where I keep getting a very non-informative SyntaxError message:
Incorporating this patch fixes it, giving me:
This is on Python 3.10.9 (the system I originally discovered this error on is Python 3.11). |
Could you add an entry to the changelog and commit a regenerated parser ? I think the fact we changed the base but did not update the parser is why appveyor is complaining but I find it a bit weird. |
tests/core/parser/test_parser.py
Outdated
lines = tb.strip().split("\n") | ||
line = '\n'.join(lines[-4:]) | ||
|
||
expected = 'enamldf CustomLabel(Container):' |
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.
There is a typo in enamldef
I added detail for indentation errors. Could you try it & cherry pick from https://github.com/frmdstryr/enaml/tree/indexerror-detail ? For some reason the generated parser is formatted weirdly so I didn't commit it. |
You need to manually run black after generating it. |
c235c42
to
0e822eb
Compare
The CIs look unhappy. I should be able to look at this during the week. |
@MatthieuDartiailh Sorry for the long delay. Finally got around to fixing the unit tests. One is still failing (upload to codecov), but I don't think that's relevant to the changes made in this commit. |
Thanks ! Could you add a changelog entry and a regenerated parser (formatted with black) ? |
@frmdstryr The errors above are related to the IndexError tests you added. It seems that Enaml is properly detecting that there is a SyntaxError; however, it's being reported as a general SyntaxError rather than an IndentationError. I'm not sure how to fix this. I also switched to your branch and tested on Python 3.10 and it's not working either. Only two of the tests (childdef-indent-mismatch and class) are being reported as IndentationErrors. All others are SyntaxErrors. Thoughts? |
Odd... seems like something with pegen 0.2.0. If you revert to I guess the parser with the latest pegen is not calling raise_indentation_error. |
@frmdstryr That explains why the tests passed at one point, but then did not pass. I was doing a line-by-line comparison and was stumped. Thanks for catching that. @MatthieuDartiailh, any thoughts? I'm not familiar with pegen, so I'm not sure where to start and whether this is a bug in Enaml or in Pegen. |
Switching to pegen 0.2.0 is somewhere on my list of things to do for 3.12. Right now I have bytecode running and atom is close but CI segfault when exiting. Next I will look into pegen (f-string require some extra work) and finally reach enaml but it will take time. For this PR simply regen with 0.1.0 and commit. You can also pin pegen if I forgot to do it. |
Pegen 0.2.0 results in some IndentationError exceptions being raised as SyntaxError instead.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #530 +/- ##
==========================================
+ Coverage 72.65% 72.73% +0.08%
==========================================
Files 287 287
Lines 24417 24425 +8
Branches 4343 4344 +1
==========================================
+ Hits 17740 17766 +26
+ Misses 5591 5580 -11
+ Partials 1086 1079 -7 |
Looks like it passed, finally. 🎉 Thanks @MatthieuDartiailh and @frmdstryr for your help! |
Thanks @bburan and @frmdstryr |
See #529 for details. Note that the unit tests I added do not actually capture the bug for some reason, but I can verify that in my own code (where I discovered the bug), the changes I made to raising SyntaxError solves the issue.