Importing bazel-generated code in the same directory as source files #10893
Replies: 2 comments
-
|
No, this isn't supported. See this issue for details. Supporting this would be theoretically possible, but it would require a pretty heavy lift because it breaks an assumption that's baked deeply into pyright's current design. Fixing it would also probably have a negative performance impact for most pyright users, so it's something I'd consider implementing only if there was significant signal from users. You're not the first person who has requested this support, but there have been only a handful of requests in the last five years — not enough to justify such a major change. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
We have a monorepo built by bazel, and it's common to have Python source files and proto files in the same directory. After a build this will end up with a runfiles directory that has the generated code and symlinks to the source files, which works fine. During development it's more trouble: the source files are in the source directory and the generated files are in bazel-bin. Like this:
pyright can resolve
from module import srcdirandfrom module import builddir, but it can't resolvefrom module import (srcdir, builddir). It seems to mapmoduleto one directory or the other. Complete example attached. Is there a way to configure pyright to make this work? It's hard to call pyright's behavior wrong here, but it's certainly inconvenient for me.pyworkspace.tar.gz
Here's the pyright output:
Beta Was this translation helpful? Give feedback.
All reactions