I am familiar with Pycharm and new to VSCode. I would like to "go to definition" like I did in Pycharm but I can’t figure out how to. Btw I set up the environment in WSL2 Ubuntu and code from local with WSL VSCode extension.
Directory tree view is like :
src
|-calculation
|-base_class.py
|-particular_class.py
|-db_related_module
|-db_class.py
and each module has:
base_class.py
class BaseClass():
def __init__(self, DbClass):
self.db_cls = DbClass
particular_class.py
from base_class import BaseClass
from db_related_module.db_class import DbClass
class ParticularCalClass(BaseClass):
def __init__(self):
super().__init__(
DbClass
)
def some_calculation(self):
do_db_stuff = self.db_cls
ret = do_db_stuff.execute_sql()
return ret
def main():
calc_cls = ParticularCalClass()
print(calc_cls.some_calculation())
main()
db_class.py
class DbClass():
def __init__(self):
pass
def execute_sql():
return "execute some sql"
Here I would like to jump from particular_class.py
ret = do_db_stuff.execute_sql()
to db_class.py
def execute_sql():
as it is the definition.
2
Answers
Normally that would be using
F12
, or right click and go to definition.After testing this is the same problem on my machine. So I filed a report on GitHub and here is their response: