I asked this a long while back, but do we have any...
# development
w
I asked this a long while back, but do we have any action hooks that can run when the global options have changed and the scheduler re-runs? I want to re-generate something based off of help, everytime the backends change
f
given rule invocations are memoized by pantsd, why not just have a rule which computes some type with that information?
and then that info should be cached
(since pantsd restart should occur for global options change, right?)
w
That would involve periodically calling said rule, no?
f
wouldn't you just call the rule when you need the computed value?
is there a code example?
w
Ah, no, looks like I missed context. I want a side-effect after each re-run after a restart due to backend/global option change. It’s for the VSCode LSP generating the
builtins.pyi
file . One option is more a polling-style, which seems strange (every time we call pants, or we call pants after checking the pants.toml and generated file timestamps - generate this file - which is my short term hack). The other option is that there was a hook or something to let me know when the global options had change, and I could add a post-restart hook that generated the builtins as a side effect
f
How does your plugin receive requests for
builtins.pyi
? I.e., is it in the request path when VSCode tries to access that file?
w
The plugin sets up BUILD files to be parsed by
pyright
as the BUILD file LSP, and
pyright
allows providing a custom
__builtins__.pyi
- so we just need it located in the project somewhere, and then we pass that into pyright's configuration
As of an update last night, the user can manually generate this builtins file from vscode (https://github.com/RobotPajamas/suspenders/blob/06ce4c16b3beeae27adcaed3b1cbba5d05bd06ec/src/extension.ts#L76-L84) - but that'll need to be automated by default, probably tonight or tomorrow. So, right now, that just tells the extension to call Pants help, and then use the stdout to generate builtins https://github.com/RobotPajamas/suspenders/blob/06ce4c16b3beeae27adcaed3b1cbba5d05bd06ec/src/lsp/client.ts#L79-L87