Open kdowney-talos opened 4 days ago
Thanks for the report. Is python_artifact
available as a top-level function? There were a handful of functions that caused grief when I was writing the pyi file, maybe that was one of them.
Yep that appears to be the issue -- in all the examples Pants has it as a top-level function, but it flags as unimported.
Okay, thanks, I'll look into it. I had made a bunch of Suspenders improvements on one of my computers that I accidentally wiped, thinking I'd already pushed all my code. So, have to go back and re-write all that stuff. 🤦🏽
I'll take a look at this as well.
Thanks. If there is any way I can help lmk. I was starting on a buck2 VSCode plugin when I switched to Pants.
Whelp, that's the problem 😄
I looked in Pants source code, and it's in pants.backend.python.macros.python_artifact
. PythonArtifact
isn't visible to the LSP either, so what's the workaround?
Using a few backends, and some JQ, I can see there aren't many type_hints
that aren't clean python, but they need to be handled.
pants help-all | jq '.. | .type_hint? // empty'
"str | http_source | pants.core.target_types.per_platform[pants.core.target_types.http_source]"
"PythonArtifact"
And in Pants mainline, there are a few JVM type_hint instances. Very few overall.
I'm going to dig around and see if I'm missing some extracted types, and in the short term, I'll probably just hardcode a list of fixes. The goal is that Pants itself handles all of this, and I'm prototyping some ideas to have a faster LSP interaction, as using the command line is really slow.
In looking at it, the more fundamental issue is that the stuff in https://www.pantsbuild.org/stable/reference/build-file-symbols/ aren't exported in the script, but more than that, they're not well defined in the help either.
That might be something to look into and improve on the Pants side.
@kdowney-talos I PRd a bit of a hack solution, where we export the rest of the build symbols, and then I added a PythonArtifact stub, and have the python_artifact/setup_py return that.
In reality, those are basically dict wrappers, so it's all a bit strange from the start.
Even after generating LSP files, I get an (invalid) warning about referencing
python_artifact()
frompython_distribution()
, as shown in this screenshot:Maybe that symbol is missing? The targets themselves are correctly picked up.
This is with v0.0.3 pre-release on latest VSCode with pants 2.23.0.