News for hackers. Stuff that matters.
Re:The Era of Visual Studio Code by 0x008 on Wednesday September 23, 2020 @02:03AM (#24563503)
Sorry to spoil the party here but I wouldn’t call it excellent. I need to set environment variables and PYTHONPATH in 3 places (for the integrated terminal, for background processes and for the debugger). New environments are only detected after restart of the UI and It doesn’t Index or allow go to definition for libraries downloaded via pip most of the time. Also no refactoring support...

This is really frustrating. Am I doing something wrong?

Re:The Era of Visual Studio Code by hgoury on Wednesday September 23, 2020 @02:27AM (#24563642)
In my company we use pyenv with virtualenv and everything works seamlessly. VSCode automatically runs the activate script from pyenv in a new terminal (in my case it is even the fish shell), debugging works fine, and I can go to definitions.

Note that a new extension, that works alongside the original python extension, has been developed by Microsoft: Pylance. It speeds things up based on pyright, a python type-checker.

For refactoring you can use rope [0] as a VSCode extension.

[0] https://github.com/python-rope/rope

Re:The Era of Visual Studio Code by 0x008 on Wednesday September 23, 2020 @04:18AM (#24564391)
Hey, thanks for your input. I will look into using pyenv so that might solve my problem with "go to definitions".

However, I was also having a lot of trouble with environment variables, especially PYTHONPATH. How do you solve that?

Also rope did NOT work well for me. When I tried to refactor (rename) a function definition, it also changed variables in unrelated scopes that had the same name and were not related to the function at all. So I did not gain anything from that which I couldn't achieve using CTRL+F replace.

Re:The Era of Visual Studio Code by hgoury on Wednesday September 23, 2020 @07:09AM (#24565512)
I've never had any trouble with PYTHONPATH, I guess this is solved by pyenv with virtualenv. You just need to select the project interpreter the first time you open the project and it should just work.

I haven't used rope extensively, it's too bad that it doesn't work well. It's open source so I guess it needs more contributions.

Re:The Era of Visual Studio Code by joppy on Wednesday September 23, 2020 @06:07AM (#24565146)
Yeah, my experience of attempting a very simple refactor (change variable name) with the VSCode Python plug-in is:

“Rope is not installed. Install?” - so I need a package in my virtual env just to rename variables?

“Rope is installed. Refactoring failed”.