Skip to content

How to Go to Definition with specified src if I have a cloned repo in the workspace and a pip package at the same time? #5147

Answered by rchiodo
bruce2233 asked this question in Q&A
Discussion options

You must be logged in to vote

What you're really asking is the priority of different paths for resolving where an import comes from. The source for this actually is actually open sourced:
https://github.com/microsoft/pyright/blob/60e4050e0a48a47c6a265f33b5d5084c095f8fd5/packages/pyright-internal/src/analyzer/importResolver.ts#L1550

The order it searches looks like:

  • stubPath
  • root folder (or workspace folder)
  • extraPaths
  • site-packages (third party)
  • then calls into Pylance which adds the bundled stubs (which are treated as third party).

The _pickBestImport then picks the paths that are considered local over 3rd party.

Sorry, but I don't think it's possible to get it to pick the pip installed version. In that algorithm a…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@bruce2233
Comment options

Answer selected by bruce2233
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants