如何确保vscode-python正确显示来自`flake8-rst-docstrings`和/或`flake8-black` flake8扩展名的linter条目? - python

与其他flake8扩展名(例如:flake8-rst-docstrings),flake8-rst-docstringsflake8-black输出代码相反,它们使用3个字母字符而不是1个字母(RST299BLK100D204),这似乎可以防止在vscode-python的“问题”选项卡中显示这些条目。

对于以下代码段:

from collections import \
    namedtuple, \
    deque

class ControlAlgoCoreSimpleSlots:
    """My non pydocstring compliant
    summary which should make `flake8-docstrings` bark.

    Here's some markdown code block (non valid sphinx syntax
    which should make `flake8-rst-docstrings` bark.

    ```
    def my_blocking_closure_fn():
        return long_blocking_call_on(my_argument_data)
    return self.make_blocking_job(my_blocking_closure_fn)
    ```
    """
    pass

flake8报告:

$ flake8 '--format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s' ./mymodule.py
1,1,F,F401:'collections.namedtuple' imported but unused
1,1,F,F401:'collections.deque' imported but unused
1,1,D,D100:Missing docstring in public module
1,25,B,BLK100:Black would make changes.
5,1,E,E302:expected 2 blank lines, found 1
6,1,D,D204:1 blank line required after class docstring
6,1,D,D205:1 blank line required between summary line and description
6,1,D,D400:First line should end with a period
12,1,R,RST299:Inline literal start-string without end-string.
14,1,R,RST301:Unexpected indentation.
15,1,R,RST201:Block quote ends without a blank line; unexpected unindent.
15,1,R,RST299:Inline literal start-string without end-string.
15,1,R,RST299:Inline interpreted text or phrase reference start-string without end-string.

而vscode缺少vscodeRST条目。请参考vscode-python/issues/4074以获得vscode输出的图像,因为我不允许在此处发布它。

我在BLK上有礼貌地报告了vscode-python/issues/4074,但是这个d3r3kk家伙立即并突然关闭了涉及flake8 linting documentation for vscode的问题,而没有对我的问题的任何具体解决方案。

任何人都可以帮助我设置vscode-python以便我可以获取所有的linter条目,包括来自vscode-pythonflake8-rst-docstrings的那些条目吗?

参考方案

您对https://github.com/Microsoft/vscode-python/issues/4074绝对正确-这是vscode中的错误,并且您的修复程序很明智。我也在那里评论过。

较长的代码反映了flake8 v3中的更改,http://flake8.pycqa.org/en/latest/plugin-development/registering-plugins.html

  请注意:从Flake8 3.0开始,您的输入点不必完全是4个字符。考虑使用3个字母后跟3个数字(即ABC123)的入口点。

一个字母和三个数字的原始约定导致了许多flake8插件代码冲突。

披露:flake8-rst-docstringsflake8-black的作者-感谢您尝试!
https://github.com/peterjc/flake8-rst-docstrings
https://github.com/peterjc/flake8-black

Python GPU资源利用 - python

我有一个Python脚本在某些深度学习模型上运行推理。有什么办法可以找出GPU资源的利用率水平?例如,使用着色器,float16乘法器等。我似乎在网上找不到太多有关这些GPU资源的文档。谢谢! 参考方案 您可以尝试在像Renderdoc这样的GPU分析器中运行pyxthon应用程序。它将分析您的跑步情况。您将能够获得有关已使用资源,已用缓冲区,不同渲染状态上…

Python sqlite3数据库已锁定 - python

我在Windows上使用Python 3和sqlite3。我正在开发一个使用数据库存储联系人的小型应用程序。我注意到,如果应用程序被强制关闭(通过错误或通过任务管理器结束),则会收到sqlite3错误(sqlite3.OperationalError:数据库已锁定)。我想这是因为在应用程序关闭之前,我没有正确关闭数据库连接。我已经试过了: connectio…

python-docx应该在空单元格已满时返回空单元格 - python

我试图遍历文档中的所有表并从中提取文本。作为中间步骤,我只是尝试将文本打印到控制台。我在类似的帖子中已经看过scanny提供的其他代码,但是由于某种原因,它并没有提供我正在解析的文档的预期输出可以在https://www.ontario.ca/laws/regulation/140300中找到该文档from docx import Document from…

Python:集群作业管理 - python

我在具有两个阶段的计算群集(Slurm)上运行python脚本,它们是顺序的。我编写了两个python脚本,一个用于阶段1,另一个用于阶段2。每天早上,我检查所有第1阶段的工作是否都以视觉方式完成。只有这样,我才开始第二阶段。通过在单个python脚本中组合所有阶段和作业管理,是否有一种更优雅/自动化的方法?我如何知道工作是否完成?工作流程类似于以下内容:w…

Python ThreadPoolExecutor抑制异常 - python

from concurrent.futures import ThreadPoolExecutor, wait, ALL_COMPLETED def div_zero(x): print('In div_zero') return x / 0 with ThreadPoolExecutor(max_workers=4) as execut…