two issues with pyright: in the pants sandbox, it ...
# general
b
two issues with pyright: in the pants sandbox, it adds in a pyrightconfig.json which according to docs overwrites pyproject.toml configurations that I have. The second issue is that my pyproject.toml is not even in the sandbox. so effectively i am running pyright without any configuration..
w
https://github.com/pantsbuild/pants/blob/093d5363f85ad346daf71af657446d85d884f3b9/src/python/pants/backend/python/typecheck/pyright/subsystem.py#L42 If I'm understanding correctly, you have your config in pyproject.toml under tool.pyright, and it's not being picked up?
b
correct. the pyproject.toml is completely missing in a pants sandbox. unlike ruff which has the same pyproject.toml in the sandbox. The other issue i see an extra pyrightconfig.json that was added to the root of the pants sandbox.
w
as per the comments, pyrightconfig was added to deal with some path problems that are specific to pyright. Weird that the pyproject doesnt get added in though, it should be - but looks like it was an if/else here, so that multiple configs didn't step on each other. Can you create a GH ticket, if one doesn't exist? I can't recall how pyright works if both are specified, or whether the toml allows setting the venv path we need
👀 1
What's weird is that it should only add the .json file if it found nothing
b
thanks, bug filed: https://github.com/pantsbuild/pants/issues/20819 it turns out it can't pickup pyproject.toml in a source root, but pants check works fine if we had
root_patterns = ["/"]
. This is different from ruff because I had ruff configuration in the same pyproject.toml and pants was able to pick it up
w
Okay, that makes more sense. Ideally all of the pyproject files would be similarly picked up, according to some reasonable rules
Okay, I figured it would be something like this - ruff iterates through more directories. I just wasn't sure how that works if you have multiple pyprojects
b
for pyright, it only recognizes the pyproject.toml in cwd (the place you run it in)
w
👍 When I wrote that plugin a while back, I think I was following whatever the advice of pyright was at the time - unsure if that's changed, or if we need better docs on our side