[DX] Get code suggestions in your custom Frappe app for standard Frappe Python functions

To get code suggestions (intellisense) on your custom Frappe apps (including ERPNext) in Visual Studio Code, follow the steps below:

  1. Open your app in a VSCode workspace
  2. Create a new file called settings.json in a folder .vscode
  3. Add the following to this file:
{
    "python.analysis.extraPaths": [
        "${workspaceFolder}/../frappe"
    ],
}

What this is doing is telling VSCode to resolve paths from the frappe folder in the apps directory. You will now get code completion for all standard frappe methods in your own custom app.

Example:

Code suggestions:

11 Likes

Simply awesome. You have nailed it on code completion and type checking. It was pleasure to meet you.

1 Like

I’ve been using pyright for year+ now. Works flawlessly :grimacing:

Some suggestions:

  1. Enable auto search path instead of hardcoding it.
  2. Enable use of library code for types.
  3. Disable type checking (too much dynamic code to use this reliably)
5 Likes

I had the same problem with pyright and adapted this for Emacs.

(after! lsp-pyright
  (setq lsp-pyright-auto-search-paths t
        lsp-pyright-use-library-code-for-types t
        lsp-pyright-typechecking-mode "off"
        lsp-pyright-diagnostic-mode "openFilesOnly"))