Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyright not able to discover pyproject.toml in source root #20819

Open
bugzpodder opened this issue Apr 19, 2024 · 0 comments
Open

pyright not able to discover pyproject.toml in source root #20819

bugzpodder opened this issue Apr 19, 2024 · 0 comments
Labels

Comments

@bugzpodder
Copy link
Contributor

bugzpodder commented Apr 19, 2024

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.

@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

@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).

@bugzpodder bugzpodder added the bug label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant