feat: add public API for analysis-phase logic #2252
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a public API for rules (i.e. analysis-phase code) to use code from rules_python.
The main motivation for this is so that users can propagate PyInfo without having to know
all the fields of PyInfo and implement the merging logic. With upcoming PRs adding additional
fields to PyInfo, this becomes much more important.
The way the API is exposed is through a target. There are three reasons for this:
Within Google, this makes changes to rules_python much cheaper and easier to submit
and revert. This also allows us to worry less about the loading-phase impact of
our code.
from users. For example, if we want a flag to affect behavior, we can add it to the
API target's attributes; users don't have to add it to their rule's attributes
ctx
as an argument, it allows us to capture itand use it as part of future API calls (this isn't used now, but gives us
flexibility in the future).
Work towards #1647