8

I have a Python project in VSCode. Its structure

root
+-- docs
+-- some_other_folder
+-- src
    +-- app
    |   +-- main.py
    +-- tests
        +-- conftest.py    

conftest.py has import

from app.main import app

My task is to set src as root folder because in otherwise I got a warning Import 'app.main' could not be resolved

GhostKU
  • 1,898
  • 6
  • 23
  • 32

1 Answers1

15

Create pyrightconfig.json at the root directory of your project

Add the following config:

{
    "executionEnvironments": [
        {"root": "src"}
    ]
}

Details taken from: https://github.com/Microsoft/pyright/blob/main/docs/configuration.md

Anton Kesy
  • 119
  • 7
Sam Taylor
  • 275
  • 3
  • 13