Language server features (pylance) is no longer working by default in VScode after #10338 #7010

Closed
opened 2025-12-29 19:47:50 +01:00 by adam · 3 comments
Owner

Originally created by @kkthxbye-code on GitHub (Sep 21, 2022).

Originally assigned to: @jsenecal on GitHub.

NetBox version

v3.4.0-dev

Python version

3.10

Steps to Reproduce

  1. Clone netbox
  2. git checkout feature
  3. Run ./upgrade.sh just to create the venv and install packages. Doesn't matter that it fails migrations.
  4. Open the folder in vscode

Expected Behavior

The language server features should work out of the box as they did before the change.

Observed Behavior

The language server (pylance) finds no files as it loads the pyproject.toml but doesn't find any [tool.pyright] section.

[Info  - 8:39:56 PM] (29483) Pylance language server 2022.9.20 (pyright 95c059fa) starting
[Info  - 8:39:56 PM] (29483) pyproject.toml file found at /home/main/tmp/netbox.
[Info  - 8:39:56 PM] (29483) Loading pyproject.toml file at /home/main/tmp/netbox/pyproject.toml
[Error - 8:39:56 PM] (29483) Pyproject file "/home/main/tmp/netbox/pyproject.toml" is missing "[tool.pyright]" section.
[Info  - 8:39:56 PM] (29483) Searching for source files
[Info  - 8:39:56 PM] (29483) No source files found.

Delete pyproject.toml and language server features work again:

[Info  - 8:40:31 PM] (29483) No configuration file found.
[Info  - 8:40:31 PM] (29483) No pyproject.toml file found.
[Info  - 8:40:31 PM] (29483) Setting pythonPath for service "netbox": "/home/main/tmp/netbox/venv/bin/python"
[Warn  - 8:40:31 PM] (29483) stubPath /home/main/tmp/netbox/typings is not a valid directory.
[Info  - 8:40:31 PM] (29483) Searching for source files
[Info  - 8:40:31 PM] (29483) Auto-excluding /home/main/tmp/netbox/venv
[Info  - 8:40:31 PM] (29483) Found 607 source files

What I assume is happening is that pylance/pyright is automatically configured if no pyproject.toml file is present.

I have added the following to pyproject.toml which makes it work. I have no idea what the optimal settings are here, I just need to be able to use the type checker/go-to symbol features:

[tool.pyright]
include = ["netbox"]
exclude = [
    "**/node_modules",
    "**/__pycache__",
]
venv = "venv"

reportMissingImports = true
reportMissingTypeStubs = false

This is a regression from #10338 - maybe you can look at this @jsenecal ?

Originally created by @kkthxbye-code on GitHub (Sep 21, 2022). Originally assigned to: @jsenecal on GitHub. ### NetBox version v3.4.0-dev ### Python version 3.10 ### Steps to Reproduce 1. Clone netbox 2. `git checkout feature` 3. Run ./upgrade.sh just to create the venv and install packages. Doesn't matter that it fails migrations. 4. Open the folder in vscode ### Expected Behavior The language server features should work out of the box as they did before the change. ### Observed Behavior The language server (pylance) finds no files as it loads the pyproject.toml but doesn't find any `[tool.pyright]` section. ``` [Info - 8:39:56 PM] (29483) Pylance language server 2022.9.20 (pyright 95c059fa) starting [Info - 8:39:56 PM] (29483) pyproject.toml file found at /home/main/tmp/netbox. [Info - 8:39:56 PM] (29483) Loading pyproject.toml file at /home/main/tmp/netbox/pyproject.toml [Error - 8:39:56 PM] (29483) Pyproject file "/home/main/tmp/netbox/pyproject.toml" is missing "[tool.pyright]" section. [Info - 8:39:56 PM] (29483) Searching for source files [Info - 8:39:56 PM] (29483) No source files found. ``` Delete pyproject.toml and language server features work again: ``` [Info - 8:40:31 PM] (29483) No configuration file found. [Info - 8:40:31 PM] (29483) No pyproject.toml file found. [Info - 8:40:31 PM] (29483) Setting pythonPath for service "netbox": "/home/main/tmp/netbox/venv/bin/python" [Warn - 8:40:31 PM] (29483) stubPath /home/main/tmp/netbox/typings is not a valid directory. [Info - 8:40:31 PM] (29483) Searching for source files [Info - 8:40:31 PM] (29483) Auto-excluding /home/main/tmp/netbox/venv [Info - 8:40:31 PM] (29483) Found 607 source files ``` What I assume is happening is that pylance/pyright is automatically configured if no pyproject.toml file is present. I have added the following to pyproject.toml which makes it work. I have no idea what the optimal settings are here, I just need to be able to use the type checker/go-to symbol features: ``` [tool.pyright] include = ["netbox"] exclude = [ "**/node_modules", "**/__pycache__", ] venv = "venv" reportMissingImports = true reportMissingTypeStubs = false ``` This is a regression from #10338 - maybe you can look at this @jsenecal ?
adam added the type: bugstatus: accepted labels 2025-12-29 19:47:50 +01:00
adam closed this issue 2025-12-29 19:47:50 +01:00
Author
Owner

@kkthxbye-code commented on GitHub (Sep 21, 2022):

I just realized that #10338 is merged into develop, so you don't have to checkout feature to show the issue, you can checkout develop. #10338 is just not included in any releases yet.

@kkthxbye-code commented on GitHub (Sep 21, 2022): I just realized that #10338 is merged into develop, so you don't have to checkout feature to show the issue, you can checkout develop. #10338 is just not included in any releases yet.
Author
Owner

@jsenecal commented on GitHub (Sep 21, 2022):

I was able to reproduce this. Sorry for not catching it earlier as this does not occur in my (particular, must I say) environment.

@jsenecal commented on GitHub (Sep 21, 2022): I was able to reproduce this. Sorry for not catching it earlier as this does not occur in my (particular, must I say) environment.
Author
Owner
@jsenecal commented on GitHub (Sep 21, 2022): Related upstream issues, for completeness sake: https://github.com/microsoft/pylance-release/issues/3366 https://github.com/microsoft/pylance-release/issues/3363 https://github.com/microsoft/pylance-release/issues/3348
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7010