This hook is called in the coordinator with the parsed tree, but we don't want to deserialize trees in coordinator. It is currently used by mypyc, but it only accesses fullname on it. I recently recommended his hook in #17410 so it may be used by some plugins.
This hook is also used by the old NumPy plugin (in a somewhat controversial way). However, it looks like it can be fixed (in the sense that it will not immediately crash) by simply doing tree.defs = tree.imports.copy() before calling the hook.
I propose to make something like this documented behavior: i.e. explicitly say in the docs that the hook will be given partially parsed tree where only imports are available, the caller may then add extra dependencies judging from those imports.
It would be unfortunate to break plugins, but I don't see other options yet.
cc @JukkaL
This hook is called in the coordinator with the parsed tree, but we don't want to deserialize trees in coordinator. It is currently used by mypyc, but it only accesses fullname on it. I recently recommended his hook in #17410 so it may be used by some plugins.
This hook is also used by the old NumPy plugin (in a somewhat controversial way). However, it looks like it can be fixed (in the sense that it will not immediately crash) by simply doing
tree.defs = tree.imports.copy()before calling the hook.I propose to make something like this documented behavior: i.e. explicitly say in the docs that the hook will be given partially parsed tree where only imports are available, the caller may then add extra dependencies judging from those imports.
It would be unfortunate to break plugins, but I don't see other options yet.
cc @JukkaL