I also got this error. However, it affected only part of the code, not all of it.
Then I noticed that I had the following line of code somewhere in the middle of the script:
sys.exit()
with the intention of forcing the script to stop at that line.
I commented that statement, and the navigation to all declarations started working for all code below.
It looks like PyCharm has a logic not to navigate to declarations for code that is not reachable.
You should check if your code is reachable at the line where you are using a declaration you want to navigate to.