0

I am learning how to use VS code and in the process, I learnt about linting and formatting with "pylint" and "black" respectively.

Importantly, I have Anaconda installed as I often use conda environments for my different projects. I have therefore installed "pylint" and "black" into my conda environment.

My questions are as follows:

  • If "pylint" and "black" are Python packages, why do they not need to be imported into your script when you use them? (i.e. "import pylint" and "import black" at the top of a Python script you want to run). I am very new to VS code, linting and formatting so maybe I'm missing something obvious but how does VS code know what to do when I select "Run Linting" or "Format document" in the command palette? Or is this nothing to do with VS code ?

I guess I am just suprised at the fact we don't need to import these packages to use them. In contrast you would always be using import for other packages (sys, os, or any other).

  • I'm assuming if I used a different conda environment, I then need to install pylint and black again in it right?
ESCoder
  • 15,431
  • 2
  • 19
  • 42
mf94
  • 439
  • 4
  • 19

1 Answers1

0
  1. Yes, black and pylint are only available in the conda environment you installed them in. You can find them in the "Scripts"-folder of your environment.
  2. VS Code knows where to look for those scripts, I guess you can set which package is used for "Run Linting" or "Format document".
  3. You only need to import python modules or functions that you want to use inside your python module. But that's not what you do.
Niclas von Caprivi
  • 709
  • 1
  • 7
  • 12