unpythonic icon indicating copy to clipboard operation
unpythonic copied to clipboard

Support Python 3.10+ changes to the AST

Open Technologicat opened this issue 1 year ago • 1 comments

There have been some recent changes to the Python AST:

  • Python 3.10: match/case (pattern matching, now a native Python feature)
  • Python 3.11: try/except* (exception groups)
  • Python 3.12: type statement (type alias)

Full details in official docs.

Question is, what do we need to change in unpythonic to support these? At least:

  • DONE in 58388fc: lazify and autocurry should not recurse into ast.TypeAlias, because lazifying or autocurrying a type declaration makes no sense.
  • DONE in 040e333: Anything that touches on exception handling in the macro layer needs to detect TryStar as well as Try.
    • Not much detects Try; just autoreturn and scopeanalyzer.
  • DONE in faab516: Anything that detects binding forms needs to detect captures in match/case.
    • It seems unpythonic/syntax/scopeanalyzer.py is the only such part. But this is used in the let constructs (including do) as well as in lazify, so fixing that should be enough.
    • Bindings from the type statement are handled automatically by the old machinery, because they are names in Store context.

Anything else I'm missing?

Technologicat avatar Sep 27 '24 11:09 Technologicat

Since the parts I'm aware of are now done, but there may still be something I've missed, I'm keeping this ticket open, but moving it to the 0.15.4 milestone.

Technologicat avatar Sep 27 '24 13:09 Technologicat