<#20819 pyright not able to discover pyproject.tom...
# github-notifications
c
#20819 pyright not able to discover pyproject.toml in source root Issue created by bugzpodder Describe the bug Repo: https://github.com/bugzpodder/example-python I have a source root in /helloworld/ and a pyproject.toml there. (I also tested without source roots, and pants + pyright worked with no issues) When I run pyright in /helloworld/ without pants, it works fine (my current workflow) When I run
pants check ::
in root dir, it does not work because it can't find pyproject.toml This is different from pants' ruff integration where it is able to work with the pyproject.toml with no issues.
Copy code
@bugzpodder ➜ /workspaces/example-python/helloworld (main) $ pyright
0 errors, 0 warnings, 0 informations 
@bugzpodder ➜ /workspaces/example-python/helloworld (main) $ cd ..
@bugzpodder ➜ /workspaces/example-python (main) $ pants check
@bugzpodder ➜ /workspaces/example-python (main) $ pants check ::
16:05:24.63 [INFO] Completed: Force venv to materialize
16:05:29.04 [INFO] Completed: Run Pyright on 8 files.
16:05:29.04 [ERROR] Completed: Typecheck using Pyright - pyright - pyright failed (exit code 1).
helloworld/greet/greeting_test.py
  helloworld/greet/greeting_test.py:9:26 - error: Argument of type "Literal['test']" cannot be assigned to parameter "name" of type "int" in function "greet"
    "Literal['test']" is incompatible with "int" (reportGeneralTypeIssues)
1 error, 0 warnings, 0 informations



✕ pyright failed.
If you check the sandbox, you'll see it added pyrightconfig.json but it did not pick up pyproject.toml in helloworld
Copy code
@bugzpodder ➜ /workspaces/example-python (main) $ ls /tmp/pants-sandbox-OCpc9c
__node                                                                          helloworld          requirements_venv.pex
__run.sh                                                                        pyrightconfig.json  requirements_venv.pex_bin_python_shim.sh
_binary_shims_d71438cc82ac7616b94db5246abc83b636b9bc4e66183a6ff021d42bf26ed483  requirements.pex    requirements_venv.pex_pex_shim.sh

@bugzpodder ➜ /workspaces/example-python (main) $ ls /tmp/pants-sandbox-OCpc9c/helloworld/
__init__.py  greet  main.py  translator
Pants version 2.20 OS MacOS locally, the repo above is from a VSCode sandbox (linux) Additional info for running pyright outside of pants, it only recognizes the pyproject.toml in cwd (the place you run it in). pantsbuild/pants