pyan icon indicating copy to clipboard operation
pyan copied to clipboard

Add support for Python 3.8 and later

Open Technologicat opened this issue 4 years ago • 5 comments
trafficstars

We need to support ast.NamedExpr a.k.a. the walrus operator (name := value).

That's probably the only AST change that Pyan needs to be aware of. To be sure, check GTS, and mcpyrate's unparser (to which I added Python 3.8 support already).

Technologicat avatar Dec 10 '20 13:12 Technologicat

Eh, there's also ast.Constant, to replace the old constant types (Num, Str, Bytes, NameConstant, Ellipsis). Python 3.6 already has ast.Constant, but doesn't use it; Python 3.8 changes the compiler to actually emit ast.Constant.

Technologicat avatar Dec 10 '20 13:12 Technologicat

We currently have issues with projects that do not have an __init__.py in every directory that is a package.

jdb78 avatar Jan 05 '21 15:01 jdb78

@jdb78: good to know, thanks.

In other news, for 3.8, we should also add support for __pypackages__ (PEP 582 - Python local packages directory). The __pypackages__ directory itself needs to be omitted from the dotted name of the module when Pyan generates the fully qualified module name from a .py filename.

These should also be preferred over site-packages, but for that, maybe a simple rule to prefer earlier entries on the command line (plus instructions saying so) might be enough in practice.

Technologicat avatar Jan 14 '21 13:01 Technologicat

Heads-up for 3.9: the AST format has changed again. As of February 2021, this isn't yet documented in GTS.

Particularly, at least ast.Subscript now no longer has ast.Index and ast.ExtSlice containers. Good riddance, the new design is better - but the change causes some headaches to tools that rely on the AST format. (See https://github.com/Technologicat/mcpyrate/issues/20.)

Might be that Pyan, in particular, doesn't have to care about this change - but it's something we should verify before adding a python39 label.

I don't know yet about other AST changes in 3.9 or 3.10. I'll keep an eye out for them.

Technologicat avatar Feb 12 '21 00:02 Technologicat

No other AST changes in 3.9 or 3.10... except the new source location fields (end_lineno, end_col_offset), which we don't need here.

Technologicat avatar Jun 27 '22 09:06 Technologicat