Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 97473

Fixing 'Import [module] could not be resolved' in pyright

$
0
0

I'm using pyright for type checking and I'm also using pytest for testing inside Visual Studio Code. The folder structure for my tests is to have a 'test' subfolder in the package root . For example

|
MyPackage
|-- __init__.py
|-- MyModule.py
|--test
   |-- __init__.py
   |--MyModule_test.py

I'm organizing things like this as there will be many packages and I want to keep things organized. Inside pytest I have

import pytest
import MyPackage.MyModule 
...

Pytest is able to discover the tests and run them OK because it has some special ability to adjust its sys.path (or something). However, pyright will just complain that it cannot import the module, Import 'MyPackage.MyModule' could not be resolvedpyright (reportMissingImports). This makes sense, but is there some way to deal with this, either in pyright or in the Visual Studio Code settings to stop this from complaining?


Viewing all articles
Browse latest Browse all 97473

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>