microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.72k stars 766 forks source link

Have "Go to Definition" respect .env settings for PYTHONPATH #1850

Closed xobs closed 3 years ago

xobs commented 6 years ago

Environment data

Actual behavior

Control-clicking on a symbol does nothing, pressing F12 says "No definition found", mousing-over shows the function definition.

Expected behavior

If a definition is available, such as by mousing-over a symbol, then control-clicking on the symbol should go to the definition.

Steps to reproduce:

  1. Check out the repository
  2. Create the env file with "python ws2812b-catcher.py --lx-print-env > .env"
  3. Restart vscode

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Starting Microsoft Python language server.
[Info  - 4:47:32 PM] Created Microsoft.PythonTools.Interpreter.Ast.AstPythonInterpreter instance from Microsoft.PythonTools.Interpreter.Ast.AstPythonInterpreterFactory
Initializing for C:\Python37\python.exe
Loading files from c:\Users\smcro\Documents\Code\Chibitronics\ws2812b-catcher
##########Linting Output - pylint##########
************* Module ws2812b-catcher
24,8,error,E1101:Instance of 'ClockGen' has no 'specials' member
21,8,warning,W0612:Unused variable 'rst'
52,16,error,E1123:Unexpected keyword argument 'default' in constructor call
62,8,error,E1101:Instance of 'WS2812bPhy' has no 'sync' member
114,8,error,E1101:Instance of 'WS2812bSpecCatcher' has no 'comb' member
11,0,warning,W0614:Unused import DUID from wildcard import
11,0,warning,W0614:Unused import wrap from wildcard import
11,0,warning,W0614:Unused import Mux from wildcard import
11,0,warning,W0614:Unused import Cat from wildcard import
11,0,warning,W0614:Unused import Replicate from wildcard import
11,0,warning,W0614:Unused import Constant from wildcard import
11,0,warning,W0614:Unused import C from wildcard import
11,0,warning,W0614:Unused import ClockSignal from wildcard import
11,0,warning,W0614:Unused import ResetSignal from wildcard import
11,0,warning,W0614:Unused import Case from wildcard import
11,0,warning,W0614:Unused import Array from wildcard import
11,0,warning,W0614:Unused import SPECIAL_INPUT from wildcard import
11,0,warning,W0614:Unused import SPECIAL_OUTPUT from wildcard import
11,0,warning,W0614:Unused import SPECIAL_INOUT from wildcard import
11,0,warning,W0614:Unused import collections from wildcard import
11,0,warning,W0614:Unused import FinalizeError from wildcard import
11,0,warning,W0614:Unused import combinations from wildcard import
11,0,warning,W0614:Unused import flat_iteration from wildcard import
11,0,warning,W0614:Unused import rename_clock_domain from wildcard import
11,0,warning,W0614:Unused import Special from wildcard import
11,0,warning,W0614:Unused import Tristate from wildcard import
11,0,warning,W0614:Unused import TSTriple from wildcard import
11,0,warning,W0614:Unused import READ_FIRST from wildcard import
11,0,warning,W0614:Unused import WRITE_FIRST from wildcard import
11,0,warning,W0614:Unused import NO_CHANGE from wildcard import
11,0,warning,W0614:Unused import Memory from wildcard import
11,0,warning,W0614:Unused import itemgetter from wildcard import
11,0,warning,W0614:Unused import bits_for from wildcard import
11,0,warning,W0614:Unused import value_bits_sign from wildcard import
11,0,warning,W0614:Unused import list_signals from wildcard import
11,0,warning,W0614:Unused import list_targets from wildcard import
11,0,warning,W0614:Unused import list_inputs from wildcard import
11,0,warning,W0614:Unused import group_by_targets from wildcard import
11,0,warning,W0614:Unused import list_special_ios from wildcard import
11,0,warning,W0614:Unused import list_clock_domains_expr from wildcard import
11,0,warning,W0614:Unused import list_clock_domains from wildcard import
11,0,warning,W0614:Unused import is_variable from wildcard import
11,0,warning,W0614:Unused import generate_reset from wildcard import
11,0,warning,W0614:Unused import insert_reset from wildcard import
11,0,warning,W0614:Unused import insert_resets from wildcard import
11,0,warning,W0614:Unused import lower_basics from wildcard import
11,0,warning,W0614:Unused import lower_complex_slices from wildcard import
11,0,warning,W0614:Unused import rename_clock_domain_expr from wildcard import
11,0,warning,W0614:Unused import call_special_classmethod from wildcard import
11,0,warning,W0614:Unused import lower_specials from wildcard import
11,0,warning,W0614:Unused import NodeVisitor from wildcard import
11,0,warning,W0614:Unused import NodeTransformer from wildcard import
11,0,warning,W0614:Unused import get_obj_var_name from wildcard import
11,0,warning,W0614:Unused import verilog_printexpr from wildcard import
11,0,warning,W0614:Unused import log2_int from wildcard import
11,0,warning,W0614:Unused import f from wildcard import
11,0,warning,W0614:Unused import ModuleTransformer from wildcard import
11,0,warning,W0614:Unused import ControlInserter from wildcard import
11,0,warning,W0614:Unused import CEInserter from wildcard import
11,0,warning,W0614:Unused import ResetInserter from wildcard import
11,0,warning,W0614:Unused import ClockDomainsRenamer from wildcard import
11,0,warning,W0614:Unused import FullMemoryWE from wildcard import
11,0,warning,W0614:Unused import MemoryToArray from wildcard import
11,0,warning,W0614:Unused import SplitMemory from wildcard import
11,0,warning,W0614:Unused import gcd_multiple from wildcard import
11,0,warning,W0614:Unused import Simulator from wildcard import
11,0,warning,W0614:Unused import run_simulation from wildcard import
11,0,warning,W0614:Unused import passive from wildcard import
11,0,warning,W0614:Unused import DIR_NONE from wildcard import
11,0,warning,W0614:Unused import DIR_S_TO_M from wildcard import
11,0,warning,W0614:Unused import DIR_M_TO_S from wildcard import
11,0,warning,W0614:Unused import set_layout_parameters from wildcard import
11,0,warning,W0614:Unused import layout_len from wildcard import
11,0,warning,W0614:Unused import layout_get from wildcard import
11,0,warning,W0614:Unused import layout_partial from wildcard import
11,0,warning,W0614:Unused import Record from wildcard import
11,0,warning,W0614:Unused import reduce from wildcard import
11,0,warning,W0614:Unused import or_ from wildcard import
11,0,warning,W0614:Unused import AnonymousState from wildcard import
11,0,warning,W0614:Unused import NextState from wildcard import
11,0,warning,W0614:Unused import NextValue from wildcard import
11,0,warning,W0614:Unused import FSM from wildcard import
11,0,warning,W0614:Unused import OrderedDict from wildcard import

----------------------------------------------------------------------

Your code has been rated at -11.52/10 (previous run: -11.52/10, +0.00)

[Info  - 4:50:27 PM] Found 310 completions for file:///c:/Users/smcro/Documents/Code/Chibitronics/ws2812b-catcher/ws2812b-catcher.py at (52, 29) after filtering
##########Linting Output - pylint##########
************* Module ws2812b-catcher
24,8,error,E1101:Instance of 'ClockGen' has no 'specials' member
21,8,warning,W0612:Unused variable 'rst'
62,8,error,E1101:Instance of 'WS2812bPhy' has no 'sync' member
114,8,error,E1101:Instance of 'WS2812bSpecCatcher' has no 'comb' member
11,0,warning,W0614:Unused import DUID from wildcard import
11,0,warning,W0614:Unused import wrap from wildcard import
11,0,warning,W0614:Unused import Mux from wildcard import
11,0,warning,W0614:Unused import Cat from wildcard import
11,0,warning,W0614:Unused import Replicate from wildcard import
11,0,warning,W0614:Unused import Constant from wildcard import
11,0,warning,W0614:Unused import C from wildcard import
11,0,warning,W0614:Unused import ClockSignal from wildcard import
11,0,warning,W0614:Unused import ResetSignal from wildcard import
11,0,warning,W0614:Unused import Case from wildcard import
11,0,warning,W0614:Unused import Array from wildcard import
11,0,warning,W0614:Unused import SPECIAL_INPUT from wildcard import
11,0,warning,W0614:Unused import SPECIAL_OUTPUT from wildcard import
11,0,warning,W0614:Unused import SPECIAL_INOUT from wildcard import
11,0,warning,W0614:Unused import collections from wildcard import
11,0,warning,W0614:Unused import FinalizeError from wildcard import
11,0,warning,W0614:Unused import combinations from wildcard import
11,0,warning,W0614:Unused import flat_iteration from wildcard import
11,0,warning,W0614:Unused import rename_clock_domain from wildcard import
11,0,warning,W0614:Unused import Special from wildcard import
11,0,warning,W0614:Unused import Tristate from wildcard import
11,0,warning,W0614:Unused import TSTriple from wildcard import
11,0,warning,W0614:Unused import READ_FIRST from wildcard import
11,0,warning,W0614:Unused import WRITE_FIRST from wildcard import
11,0,warning,W0614:Unused import NO_CHANGE from wildcard import
11,0,warning,W0614:Unused import Memory from wildcard import
11,0,warning,W0614:Unused import itemgetter from wildcard import
11,0,warning,W0614:Unused import bits_for from wildcard import
11,0,warning,W0614:Unused import value_bits_sign from wildcard import
11,0,warning,W0614:Unused import list_signals from wildcard import
11,0,warning,W0614:Unused import list_targets from wildcard import
11,0,warning,W0614:Unused import list_inputs from wildcard import
11,0,warning,W0614:Unused import group_by_targets from wildcard import
11,0,warning,W0614:Unused import list_special_ios from wildcard import
11,0,warning,W0614:Unused import list_clock_domains_expr from wildcard import
11,0,warning,W0614:Unused import list_clock_domains from wildcard import
11,0,warning,W0614:Unused import is_variable from wildcard import
11,0,warning,W0614:Unused import generate_reset from wildcard import
11,0,warning,W0614:Unused import insert_reset from wildcard import
11,0,warning,W0614:Unused import insert_resets from wildcard import
11,0,warning,W0614:Unused import lower_basics from wildcard import
11,0,warning,W0614:Unused import lower_complex_slices from wildcard import
11,0,warning,W0614:Unused import rename_clock_domain_expr from wildcard import
11,0,warning,W0614:Unused import call_special_classmethod from wildcard import
11,0,warning,W0614:Unused import lower_specials from wildcard import
11,0,warning,W0614:Unused import NodeVisitor from wildcard import
11,0,warning,W0614:Unused import NodeTransformer from wildcard import
11,0,warning,W0614:Unused import get_obj_var_name from wildcard import
11,0,warning,W0614:Unused import verilog_printexpr from wildcard import
11,0,warning,W0614:Unused import log2_int from wildcard import
11,0,warning,W0614:Unused import f from wildcard import
11,0,warning,W0614:Unused import ModuleTransformer from wildcard import
11,0,warning,W0614:Unused import ControlInserter from wildcard import
11,0,warning,W0614:Unused import CEInserter from wildcard import
11,0,warning,W0614:Unused import ResetInserter from wildcard import
11,0,warning,W0614:Unused import ClockDomainsRenamer from wildcard import
11,0,warning,W0614:Unused import FullMemoryWE from wildcard import
11,0,warning,W0614:Unused import MemoryToArray from wildcard import
11,0,warning,W0614:Unused import SplitMemory from wildcard import
11,0,warning,W0614:Unused import gcd_multiple from wildcard import
11,0,warning,W0614:Unused import Simulator from wildcard import
11,0,warning,W0614:Unused import run_simulation from wildcard import
11,0,warning,W0614:Unused import passive from wildcard import
11,0,warning,W0614:Unused import DIR_NONE from wildcard import
11,0,warning,W0614:Unused import DIR_S_TO_M from wildcard import
11,0,warning,W0614:Unused import DIR_M_TO_S from wildcard import
11,0,warning,W0614:Unused import set_layout_parameters from wildcard import
11,0,warning,W0614:Unused import layout_len from wildcard import
11,0,warning,W0614:Unused import layout_get from wildcard import
11,0,warning,W0614:Unused import layout_partial from wildcard import
11,0,warning,W0614:Unused import Record from wildcard import
11,0,warning,W0614:Unused import reduce from wildcard import
11,0,warning,W0614:Unused import or_ from wildcard import
11,0,warning,W0614:Unused import AnonymousState from wildcard import
11,0,warning,W0614:Unused import NextState from wildcard import
11,0,warning,W0614:Unused import NextValue from wildcard import
11,0,warning,W0614:Unused import FSM from wildcard import
11,0,warning,W0614:Unused import OrderedDict from wildcard import

----------------------------------------------------------------------

Your code has been rated at -10.43/10 (previous run: -11.52/10, +1.09)

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:1375  INFO no standard startup: not a new window
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270 [Extension Host]% Object
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:270
workbench.main.js:sourcemap:270 [Extension Host]% Object
t.log @ workbench.main.js:sourcemap:270
workbench.main.js:sourcemap:270 [Extension Host]% Object
t.log @ workbench.main.js:sourcemap:270
workbench.main.js:sourcemap:270 [Extension Host]% Object
t.log @ workbench.main.js:sourcemap:270
workbench.main.js:sourcemap:270 [Extension Host]% Object
t.log @ workbench.main.js:sourcemap:270
workbench.main.js:sourcemap:270 [Extension Host]% Object
t.log @ workbench.main.js:sourcemap:270
workbench.main.js:sourcemap:270 [Extension Host]% Object
t.log @ workbench.main.js:sourcemap:270
workbench.main.js:sourcemap:270 [Extension Host]% Object
t.log @ workbench.main.js:sourcemap:270
workbench.main.js:sourcemap:270 [Extension Host]% Object
t.log @ workbench.main.js:sourcemap:270
workbench.main.js:sourcemap:270 [Extension Host]% Object
t.log @ workbench.main.js:sourcemap:270
brettcannon commented 6 years ago

The reason it isn't working is because code navigation doesn't use PYTHONPATH as specified in your .env file.

You can work around this by setting your "python.autoComplete.extraPaths" as necessary, e.g.:

"python.autoComplete.extraPaths": [
        "${workspaceFolder}\\deps\\litex"
    ]

will let you navigate from to Platform from from litex.boards.platforms.icestick import Platform.

d3r3kk commented 6 years ago

Related: microsoft/vscode-python#2312

xobs commented 6 years ago

Will the contents of .env be used at some point?

brettcannon commented 6 years ago

@xobs not sure yet. We need to discuss it on the team and think through the ramifications of that decision.

DonJayamanne commented 6 years ago

@brettcannon, I was under the impression the value for PYTHONPATH was being used by the language server. I remember having a chat about this with @mikhail. It either got missed out it accidentally dropped off at done point in time

brettcannon commented 6 years ago

@DonJayamanne I think you meant to ask @MikhailArkhipov 😉

But my question is whether we are always sourcing a .env file to calculate PYTHONPATH for things like the language server?

DonJayamanne commented 6 years ago

But my question is whether we are always sourcing a .env file to calculate PYTHONPATH for things like the language server?

No we aren't, I checked this yesterday.

We need to use the IEnvironmentVariablesService (or similar name, can't remember) to get these resolved variables and pass into the language server.

xobs commented 6 years ago

It should be noted that you need both python.autoComplete.extraPaths and the .env file for both the Python Language Server and pylint to work. If you only specify one, you'll get some strange behavior.

DRuiz42 commented 5 years ago

The reason it isn't working is because code navigation doesn't use PYTHONPATH as specified in your .env file.

You can work around this by setting your "python.autoComplete.extraPaths" as necessary, e.g.:

"python.autoComplete.extraPaths": [
        "${workspaceFolder}\\deps\\litex"
    ]

will let you navigate from to Platform from from litex.boards.platforms.icestick import Platform.

Where are you supposed to add those lines?

EDIT: Answer : settings.json that you can access through Ctrl + shift + P > Preferences: Open Settings (JSON)

schperplata commented 4 years ago

@DonJayamanne Is this a temporary solution, or is this the approach VS Code will stick with?

As I can see, this is really not a convenient way: .env file nicely pack all environment variables into one place and therefore duplicating this items in settings.json (or any other file than .env) just makes a whole lot of maintenance problems. Also, system environment variables are discovered inside .env files, while VS Code is quite messy where and what environment substitution is possible, for example even main .code-workspace file doesn't support basic env stuff...

I am switching back to Jedi, since IntelliCode doesn't work in our environment.

brettcannon commented 4 years ago

@schperplata we're hoping to plumb .env support throughout the extension at some point.

luabud commented 3 years ago

We can check if this is fixed when https://github.com/microsoft/vscode-python/issues/11995 lands

judej commented 3 years ago

This should be fixed as part of the #275

akapocsi commented 3 years ago

@judej This does not appear to be fixed as part of #275

jakebailey commented 3 years ago

Please file a new issue for your case; this issue definitely was closed as we could navigate and resolve imports as we would had they been populated in extraPaths.