Closed ErikSchierboom closed 7 months ago
The library that was used to turn an AST
back into code in the representer (astor) does not appear to be maintained for more recent versions of Python, so it chokes on things like structural pattern matching and the walrus operator (:=
).
Fortunately core Python added ast.unparse
in Python 3.8, and it was always slightly preferable to use only core Python for the representer anyways. Pull 45 replaces astor
with ast.unparse
, among other refactorings that fixes this bug.
edited to add: Actually, it does look like the astor
folx have tried to bring the library up to date for match
statements. However, I don't want to rely on them and have this break every time a new feature is added but the team is behind. I'd rather rely on the core Python team and the built-in AST lib since it is more stable and up-to-date.
Sadly, I've gotten sideswiped by writing a bunch of approaches and reviewing concepts that Colin is writing (and other life things) -- so I never got back to changing the representer to handle multiple student files, and we never merged Pull 45.
While I would love to do that final bit work , it feels as if maybe we merge what we have to fix this and other issues and do the representer re-runs?
I am happy to do the multi-file support, but if we wait on me for that, this bug (at the rate I am currently moving) is likely to go unfixed for another month or more.
One note: There aren't specific parsing tests for anything introduced in Python 3.9, Python 3.10, or Python 3.11, but I can add some for features I think might get high use from students. At this time, type annotations are being stripped, so there aren't any test cases needed there.
IIRC, I did make one case with pattern matching and one with a walrus. In any case, I will review and work on adding some of those today and over the weekend, just to cover our bases.
While I would love to do that final bit work , it feels as if maybe we merge what we have to fix this and other issues and do the representer re-runs?
I am happy to do the multi-file support, but if we wait on me for that, this bug (at the rate I am currently moving) is likely to go unfixed for another month or more.
As multi-file submissions will be the outlier (I can detect those and selectively re-run them), I'm totally happy with this proposed plan.
I added an issue for the multi-file handling, so I don't forget. 😄 I didn't get a chance to add more smoke tests. However, we do have one already for pattern matching, which is the big one here.
I'll make an issue to add more tests for newer features, but since the representer is now using ast.unparse
, I think we're largely "safe".
Linking PR #55 here, because in the course of writing more smoke tests, @brocla found a bug with unassigned expressions that needed fixing. This is why we test.... 😄
Since that PR is unmerged, I think I will keep this open for a little bit longer.
Closing this as fixed, at least until we find another bug. 😄
That is fantastic news. It is great to see success.
I'm going to send you another set of golden tests. This one is for dataclasses. The new features are slots and key-word-only options. All three of the examples come from exercism exercises with solutions that already use dataclasses. I just dressed them up a bit to use the new features.
BTW. I'll be out of town for a week. If there is something that you want to change in these examples, feel free. No need to wait for me.
Regards, Kevin
On Wed, Mar 27, 2024 at 11:22 AM BethanyG @.***> wrote:
Closing this as fixed, at least until we find another bug. 😄
— Reply to this email directly, view it on GitHub https://github.com/exercism/python-representer/issues/48#issuecomment-2023360053, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBULKX3YCN6SYN2PETXBGLY2L55HAVCNFSM6AAAAABEBSJ4NSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRTGM3DAMBVGM . You are receiving this because you were mentioned.Message ID: @.***>
Whilst looking into https://forum.exercism.org/t/solution-isnt-displayed-in-community-solutions/10071, I found that the representer crashes on this solution: https://exercism.org/tracks/python/exercises/sgf-parsing/solutions/Timus