Decide what to do with get_additional_deps() plugin hook
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
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 https://github.com/python/mypy/issues/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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the coordinator call to get_additional_deps() and its current users in mypyc and the old NumPy plugin. Determine whether the hook should receive a partially parsed tree with imports available, and document the decided behavior and compatibility implications for plugins.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100