Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a root directory for PyRight?

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

like image 735
GhostKU Avatar asked Jan 25 '23 05:01

GhostKU


1 Answers

Create pyrightconfig.json at the the root directory of your project

Add the following config:

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

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

like image 180
Sam Taylor Avatar answered Jan 29 '23 08:01

Sam Taylor