-
Notifications
You must be signed in to change notification settings - Fork 555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add pyi attributes/fields, original source fields #2538
Conversation
150941c
to
4a4475a
Compare
4a4475a
to
d4fcb41
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Gazelle support can come in a later PR.
FYI @ewianda, @dougthor42.
|
||
These are dependencies that satisfy imports guarded by `typing.TYPE_CHECKING`. | ||
These are build-time only dependencies and not included as part of a runnable | ||
program (packaging rules may include them, however). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gazelle has a feature that populates the deps or data field for the pyi packages that one may have in the requirement file. I am not sure how big of a lift it is to accommodate for that but it raises some questions.
- What happens if pyi sources propagate through deps vs pyi_deps.
- Do I understand correctly that the pyi_deps will not be fetched if none of the actions consumes them?
The deps attribute will try to include things into the final output for runtime. The pyi_deps attribute won't. Given a target with only pyi files (i.e it only has things for build time, nothing for runtime), it doesn't matter much if something is put into deps or pyi_deps. Given a target with e.g. both py and pyi files (i.e it has things for build time and things for runtime), putting it in pyi_deps means none of it will end up in the final output. This is useful if a source file has something guarded by
It'll be fetched, but it won't cause any actions to actually run. The analysis phase will need to resolve the target, but (assuming there is no type checker using the pyi files) none of the files/actions will be executed. |
This adds attributes and fields of use to static analysis.
For type definition files (usually
.pyi
files), thepyi_srcs
andpyi_deps
fields are added to the rules. They end up in the PyInfo fields direct_pyi_files
and transitive_pyi_files.
So that static analysis tools can retain access to a target's Python source files,
even if precompiling is enabled,
direct_original_sources
andtransitive_original_sources
fields are added to PyInfo.Work towards #2537, #296