Dear all, I was struggling with `pyright` in Pants...
# development
a
Dear all, I was struggling with
pyright
in Pants. I could verify that it breaks when using the target
::
on a big repository, at about
1,400
files, and ours has even more files. By chatting with @better-van-82973, it turned out that an additional partitioning on the files level could help in this case. I would be interested in trying to implement this myself but I'm completely lost on how to configure my IDE, visual studio code, to debug on a rule. Maybe I'm missing something, but this is what I do: 1. Once the environment is ready with rust/python, I run
pants
in the root folder. I use
pants
from
homebrew
. The process apparently succeeds and I could also verify by running
pants test src/python/pants/backend/python/typecheck/pyright/rules_integration_test.py
2. Then I link the venv to visual studio code by using the setting:
"python.defaultInterpreterPath": "~/.cache/pants/pants_dev_deps/edb7e9b2fbe8ee3a512a6fe15c1d92e1628269ed.venv/bin/python",
. It's worth noticing that the pattern is different from what is mentioned in the docs, supposed to include the architecture. I also tried to
export
in
dist
and link in the same way, but same result. However, visual studio code seems to recognize the environment corretly. 3. The I tried the following commands in the terminal: a.
PANTS_DEBUG=true pants --no-pantsd
b.
pants test --debug-adapter src/python/pants/backend/python/typecheck/pyright/rules_integration_test.py
By running with remote debugging on the file
rules_integration_test.py
I cannot make it stop at any breakpoint in
pyright_determine_partitions
. Is it because it is into an
async
function? What would it be the best way to debug this?
b
@bitter-ability-32190 I have this vague memory you've done a bunch of work on the debug-adapter functionality. Any insight?
b
Trying to debug pants tests is kinda cursed I think because there's 2 Pantss at play. I'd probably just try and run with PANTS_DEBUG and poke from there.
I don't think I've tried debugging pants since the scie-pants change, so there's a chance that didn't survive the port
a
Thank you, I ended up by writing tests directly with partial rules to isolate the output. It’s not super efficient be it works. One question: can I potentially clone the pyright backend into a plugin? I assume I’d have to make some renaming, other than registering the plugin itself. It would help to test the modifications on our monorepo, if I cannot use pants from source.
b
I think
pyright
is pip installed from the resolve you provide? If so, use a VCS URL?
b
I think the problem is that it’s not the underlying Pyright package that needs to change for this, it’s the backend code in Pants. Previously I recommended modifying the backend in a fork and running using
PANTS_SOURCE
, but I’m curious if there’s another way