https://pantsbuild.org/ logo
#general
Title
# general
b

bitter-ability-32190

08/11/2022, 4:51 PM
@wide-midnight-78598’s VS Code plugin got my gears spinning VERY hard. I completely neglected all obligations until I could get this PoC for a Pants
BUILD
file LSP. Still hand-waivey, but 🎉
🤯 3
🤩 3
⚙️ 1
It's actually quite simple: • Extend Pyright as an LSP server, with the main customization points just disabling incorrect features (like auto-import) • Have Pants generate
__builtins__.pyi
containing a definition for each target, CAOF, and object (Haven't done, the PoC just hand-wrote it for
python_sources
) • VS Code extension to wire it up
It's not perfect by any means. The biggest irk to me will be that builtins are registered definitions of
BUILD
, so it'll try and suggest
str
and
dict
.
Also, still need to figure out macros: • Tell Pyright about them for builtins sake I think if we came up with a special extension for them, linting/LSPing them wouldn't collide with Python
h

hundreds-father-404

08/11/2022, 5:07 PM
Also, still need to figure out macros:
I think this would be https://github.com/pantsbuild/pants/issues/14832
b

bitter-ability-32190

08/11/2022, 5:08 PM
How so?
For macros definitions in
BUILD
files, I was thinking of just inlining them into the builtins generated pyi
h

hundreds-father-404

08/11/2022, 5:09 PM
That PR will result in macros integrating into
help
, so we can export it to
__builtins__
. Same with our special objects like
parametrize()
b

bitter-ability-32190

08/11/2022, 5:12 PM
Oh sorry, by macros I meant
build_file_prelude_globs
h

hundreds-father-404

08/11/2022, 5:13 PM
Ah yeah, rest of the thread gets into how to handle those
🤔 1
b

bitter-ability-32190

08/11/2022, 5:16 PM
I'd love if
build_file_prelude_globs
weren't preluded, but were collected and things marked for re-exposing are done
w

wide-midnight-78598

08/11/2022, 5:24 PM
Neglect FTW!
🙌 2
5 Views