0

VSCode gives a warning whenever I import a python file from the same directory, but in practice everything works fine when the scripts run.

In a sample directory:

root_folder
+-- __init__.py (empty)
+-- __main__.py (empty)
+-- __import.py (contains Parent class)
+-- toImport.py (contains Child(Parent) class)

I try the following in toImport.py:

from __import import Parent

class Child(Parent): ...

Although I keep getting a warning: unresolved import even if it works. How can I resolve this issue or is it a VSCode issue?

1 Answers1

3

Add this to your projects .vscode/settings.json file.

{
  "python.autoComplete.extraPaths": ["./root_folder"]
}
GollyJer
  • 18,860
  • 14
  • 91
  • 148