[英]Why no need to load Python formatter (black) and linter (pylint) and vs code?
I am learning how to use VS code and in the process, I learnt about linting and formatting with "pylint"
and "black"
respectively.我正在学习如何使用 VS 代码,在此过程中,我分别了解了
"pylint"
和"black"
"pylint"
和格式化。
Importantly, I have Anaconda installed as I often use conda environments for my different projects.重要的是,我安装了 Anaconda,因为我经常在不同的项目中使用 conda 环境。 I have therefore installed
"pylint"
and "black"
into my conda environment.因此,我在
"pylint"
环境中安装了"pylint"
和"black"
。
My questions are as follows:我的问题如下:
"pylint"
and "black"
are Python packages, why do they not need to be imported into your script when you use them?"pylint"
和"black"
是 Python 包,为什么在使用它们时不需要将它们导入到您的脚本中? (ie "import pylint"
and "import black"
at the top of a Python script you want to run). "import pylint"
和"import black"
)。 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? 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).
相比之下,您将始终对其他包(sys、os 或任何其他包)使用 import。
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.black
和pylint
仅在您安装它们的 conda 环境中可用。您可以在您的环境的“脚本”文件夹中找到它们。import
python modules or functions that you want to use inside your python module.import
要在 python 模块中使用的 python 模块或函数。 But that's not what you do.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.