Skip to content

Commit

Permalink
Docs could be clearer about which .pth files work in editable insta…
Browse files Browse the repository at this point in the history
…ll scenarios (#6079)
  • Loading branch information
debonte authored Oct 3, 2023
1 parent dee4075 commit 4137f0c
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions docs/import-resolution.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,9 @@ Pyright uses the following mechanisms (in priority order) to determine which Pyt

### Editable installs

[PEP 660](https://peps.python.org/pep-0660/) enables build backends (e.g. setuptools) to
use import hooks to direct the [import machinery](https://docs.python.org/3/reference/import.html)
to the package’s source files rather than using a `.pth` file. Import hooks can provide
an editable installation that is a more accurate representation of your real installation.
However, because resolving module locations using an import hook requires executing Python
code, they are not usable by Pyright and other static analysis tools. Therefore, if your
editable install is configured to use import hooks, Pyright will be unable to find the
corresponding source files.

If you want to use static analysis tools with an editable install, you should configure
the editable install to use `.pth` files instead of import hooks. See your build backend’s
documentation for details on how to do this. We have provided some basic information for
common build backends below.
[PEP 660](https://peps.python.org/pep-0660/) enables build backends (e.g. setuptools) to use import hooks to direct the [import machinery](https://docs.python.org/3/reference/import.html) to the package’s source files rather than putting the path to those files in a `.pth` file. Import hooks can provide an editable installation that is a more accurate representation of your real installation. However, because resolving module locations using an import hook requires executing Python code, they are not usable by Pyright and other static analysis tools. Therefore, if your editable install is configured to use import hooks, Pyright will be unable to find the corresponding source files.

If you want to use static analysis tools with an editable install, you should configure the editable install to use `.pth` files that contain file paths rather than executable lines (prefixed with `import`) that install import hooks. See your build backend’s documentation for details on how to do this. We have provided some basic information for common build backends below.

#### Setuptools
Setuptools currently supports two ways to request:
Expand Down

0 comments on commit 4137f0c

Please sign in to comment.