[issue43994] change representation of match as / capture as `Name(..., ctx=Store())`

Anthony Sottile report at bugs.python.org
Fri Apr 30 23:25:43 EDT 2021


Anthony Sottile <asottile at umich.edu> added the comment:

at least for static analysis of other python constructs it's very convenient to know from a `Name` node alone whether it's being used in a read or write context -- without this information an ast traversal needs to maintain more information about whether it's a read or write context

for pyflakes this is especially important as it needs to know what names are defined in scope (and referenced in scope) to produce diagnostic messages

for other tools like `dead` / `vulture` it's useful to identify introduced and referenced names similarly

the `as` in `with` does and the target for assignment expressions so I would expect the similar constructs in `match` to do so as well

`Name` nodes are also useful for better diagnostic messages as they contain positioning information, which isn't easily extracted from `MatchAs`, etc. -- if I recall correctly, the `asname` for imports was recently extended to add this information for the same purpose

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43994>
_______________________________________


More information about the Python-bugs-list mailing list