<#17924 pyright: discrepancy between native run an...
# github-notifications
q
#17924 pyright: discrepancy between native run and Pants run Issue created by smelc Bug description
pyright
has a different behavior when launched from CLI compared to when launched with Pants. cc @sureshjoshi I have provided a minimal reproduction procedure on repository smelc/pants-implicit-namespaces-typecheck which I built from a production usecase at Kaiko. I'm reproducing below some of the content of the top-level README.md of smelc/pants-implicit-namespaces-typecheck, but please see the repo for the concerned source code. In the concerned repo, typechecking
libs/a
natively with
pyright
succeeds:
Copy code
> cd libs/a
> rm .venv -Rf; python3 -m venv .venv && source .venv/bin/activate && pip install pip==22.2.2 && pip install -r requirements.txt pyright==1.1.258
> pyright .
WARNING: there is a new pyright version available (v1.1.258 -> v1.1.287).
Please install the new version or set PYRIGHT_PYTHON_FORCE_VERSION to `latest`

No configuration file found.
pyproject.toml file found at /home/churlin/dev/pants-implicit-namespaces-typecheck/libs/a.
Loading pyproject.toml file at /home/churlin/dev/pants-implicit-namespaces-typecheck/libs/a/pyproject.toml
Assuming Python version 3.10
Assuming Python platform Linux
Auto-excluding **/node_modules
Auto-excluding **/__pycache__
Auto-excluding **/.*
stubPath /home/churlin/dev/pants-implicit-namespaces-typecheck/libs/a/typings is not a valid directory.
Searching for source files
Found 1 source file
pyright 1.1.258
0 errors, 0 warnings, 0 informations 
Completed in 0.575sec
However, typechecking
libs/a
with Pants fails:
Copy code
→ PANTS_SHA=df1c5b2418d9c62622b6039bb0fcc91b08f1dee4 ./pants check libs/a::
22:41:11.01 [ERROR] Completed: Typecheck using Pyright - pyright - pyright failed (exit code 1).
Loading configuration file at /tmp/pants-sandbox-34MAot/pyrightconfig.json
Assuming Python version 3.10
Assuming Python platform Linux
Auto-excluding **/node_modules
Auto-excluding **/__pycache__
Auto-excluding **/.*
Searching for source files
Found 1 source file
pyright 1.1.258
/tmp/pants-sandbox-34MAot/libs/a/mycorp/a/a_mod.py
  /tmp/pants-sandbox-34MAot/libs/a/mycorp/a/a_mod.py:1:20 - error: "b" is unknown import symbol (reportGeneralTypeIssues)
1 error, 0 warnings, 0 informations 
Completed in 0.746sec

stubPath /tmp/pants-sandbox-34MAot/typings is not a valid directory.



✕ pyright failed.
The weird thing is, if I launch typechecking of the entire repo, it succeeds:
Copy code
→ PANTS_SHA=df1c5b2418d9c62622b6039bb0fcc91b08f1dee4 ./pants check ::
22:41:31.02 [INFO] Completed: Typecheck using Pyright - pyright - pyright succeeded.
Loading configuration file at /tmp/pants-sandbox-9BvBCf/pyrightconfig.json
Assuming Python version 3.10
Assuming Python platform Linux
Auto-excluding **/node_modules
Auto-excluding **/__pycache__
Auto-excluding **/.*
Searching for source files
Found 3 source files
pyright 1.1.258
0 errors, 0 warnings, 0 informations 
Completed in 0.745sec

stubPath /tmp/pants-sandbox-9BvBCf/typings is not a valid directory.



✓ pyright succeeded.
(and the number of files checked everytime is correct, so it seems I didn't screw up). Also the version of
pyright
used in all scenarios is always
1.1.258
(thanks to pinning in
pants.toml
). Pants version PANTS_SHA=df1c5b2418d9c62622b6039bb0fcc91b08f1dee4 OS I am encountering the bug on Ubuntu 22.04. Python interpreter to execute
pants
is 3.9.12. pantsbuild/pants
u