Questions tagged [vscode-python]

Questions about working with Python in Visual Studio Code using the Microsoft Python extension.

This VS extension makes VS Code a python IDE. Supports any operating system with most of Python interpreters. It provides IntelliSense, linting, debugging, and unit testing, environment switch using virtual and conda environments, etc.

127 questions
6
votes
1 answer

how to configure unit test in vscode for python unittest

I am using Python 3.6 and latest version of vscode. My folder structure: /folder /src src.py /tests src_test.py src.py: class Addition: def __init__(self, a, b): self.a = a self.b = b def run(self): return…
derek
  • 9,358
  • 11
  • 53
  • 94
5
votes
1 answer

What's pylint's TypeVar name specification?

Pylint gives a warning whenever something like this happens: import typing SEQ_FR = typing.TypeVar("SEQ_FR") #^^^^^ gets underlined with the warning The warning is like this: Type variable name "SEQ_FR" doesn't conform to predefined naming style.…
TNTzx
  • 407
  • 2
  • 11
5
votes
1 answer

Get autocomplete when overriding methods from inherited python class in VS code

In IntelliJ we have a function which lets us get autcomplete and assistance for adding an inherited function. Is there any way to recreate this behaviour in VS Code with the build in Python interpreter? It lets us override specific functions by…
Andreas
  • 1,421
  • 3
  • 16
  • 32
5
votes
2 answers

On Visual Studio Code, how do I specify my pytest.ini file for test discovery

I use pytest for testing. My test files reside in a subdirectory tests and they are named Foo.py, Bar.py instead of test_Foo.py, TestFoo.py, etc. So, to make sure pytest find them, I have a pytest.ini file in the root dir of the project with the…
A.L.
  • 1,133
  • 1
  • 12
  • 19
5
votes
4 answers

VSCode: How to export a python file that was imported from a Jupyter Notebook back to Jupyter format?

Probably a silly question, but I couldn't find it. Visual Studio Code editor has a really nice way to work with Jupyter Notebooks. I can edit the cells directly in vscode and run them. Now it would be easy to work with version control. But I…
neves
  • 33,186
  • 27
  • 159
  • 192
4
votes
0 answers

Linking VS Code interactive window to running Jupyter notebook

Let's say that you have two windows open in VS Code, one is a Jupyter notebook, and the other is the Python interactive window. Both are running the same kernel. Is there a way to link these two windows, so when cells are run in the notebook, the…
Bill
  • 93
  • 1
  • 4
4
votes
0 answers

Running Python3 script in VS Code doesn't recognize environment variables unless running debugger (MacOS)

To clarify I set up the .env file for environment variables correctly and when I run the code either via the built-in terminal (default play button) or to output via the Code Runner plugin, the attempts to grab those environment variables always end…
4
votes
2 answers

How to built-in run python tox command and test in visual studio code

I have tox.ini in my project, and I want for running and showing test in visual studio code, using python tox, but I don't know how to do it?
sorosh_sabz
  • 2,356
  • 2
  • 32
  • 53
4
votes
1 answer

VSCode: how to structure a simple python package with few modules and tests, debugging and linting?

I'm having more trouble than I'd like to admit to structure a simple project in Python to develop using Visual Studio Code. How should I structure in my file system a project that is a simple Python package with a few modules? Just a bunch of *.py…
neves
  • 33,186
  • 27
  • 159
  • 192
4
votes
0 answers

Why dont i get python flask sqlalchemy autocompletion?

Why dont i get python flask sqlalchemy autocompletion? I already followed Instance of 'SQLAlchemy' has no 'Column' member (no-member) this guide and it still doesnt work. I have used both user and workspace settings. My global user settings.json…
user14662549
  • 121
  • 7
4
votes
1 answer

how to execute a shell script which sets up the python virtual environment when debugging with vscode ( What changes do i need to make to launch.json)

So i am using vscode-remote in visual studio code insiders but i think the problem i am facing with vscode-python extension. So i am trying to debug a python file . So the normal execution of the file is as follows : i enable or activate a virtual…
3
votes
0 answers

Debug tox unit tests with visual studio code

I am trying to debug an existing set of unit tests that are run with tox. I updated my launch.json file to include the following configuration: { "module": "tox", "name": "tox unit tests", "request": "launch", "type": "python", …
John
  • 65
  • 6
3
votes
1 answer

vscode/pylance auto-import incorrect root path

Let's suppose that I have a project with this file structure: project_dir └── src ├── package1 │   └── module1.py └── package2 └── module2.py When I want to use some class from module1 in some other module I type something…
Anton M.
  • 185
  • 1
  • 11
3
votes
2 answers

How to declare a class variable without a value in a way that suppresses Pylance warning

I love the typechecker in Pylance (VS Code), but there seems to be a situation that I must choose between ignoring a Pylance warning and best practice for class variable declaration. Many times, class variables are initialized using a None type in…
3
votes
0 answers

VS Code python interactive window does not clear input after execution

After recent update, my VS code does not clear input automatically after execution. See in the picture, the line used to clear itself after it was executed, ready for the next one. Now it retains, and requires manual deletion before the next one.…
howto777
  • 31
  • 1
1
2
3
8 9