← ClaudeAtlas

pyright-envslisted

Generate a pyrightconfig.json with one executionEnvironment per package so that Go to Definition in a monorepo resolves each file against its own import paths instead of another package's vendored copy of the same module. Use when Ctrl+click jumps into the wrong package, after a hard clean removed pyrightconfig.json, on a fresh clone, or when the set of packages changed. Triggers on "go to definition is going to the wrong package", "regenerate pyrightconfig", "pylance resolves the wrong copy", "regenerar pyrightconfig", "o ctrl+click foi pro pacote errado".
lucas-lima-s/claude-skill-pyright-envs · ★ 0 · Data & Documents · score 70
Install: claude install-skill lucas-lima-s/claude-skill-pyright-envs
## The problem In a monorepo where several packages each vendor their own copy of the same third-party module, a single flat Pylance/Pyright index cannot tell which copy a given file should resolve against. Picture two packages, `alpha` and `beta`, each with their own `vendor/sharedlib/` directory containing a different build of the same library. Without per-package isolation, Ctrl+click (Go to Definition) from a file in `alpha` can just as easily land in `beta`'s copy — whichever one the editor happened to index first. The bug is silent: imports still resolve, autocomplete still works, but they point at the wrong file, and refactors made through "Go to Definition" edit the wrong package. Pyright's `executionEnvironments` setting fixes this: each package gets its own `root` and its own `extraPaths`, so Pyright resolves imports for a file against that package's paths only. Hand-writing dozens of these entries for a real monorepo is not something anyone wants to do by hand, or keep in sync as packages come and go. This tool generates the whole `executionEnvironments` list from a small config file. ## How the fix works 1. Every discovered package becomes one entry: `{"root": "<package>", "extraPaths": [...]}`. 2. `extraPaths` are ordered source dirs, then vendor dirs, then shared roots, then test dirs, deduplicated. 3. A path is only emitted if it exists on disk. A configured shared root that does not exist is dropped and reported once on stderr, never silently swallow