重新格式化格式后,语法突出显示不适用于带有类型注释的VS Code中的Python

超级英雄

我正在尝试使Visual Studio代码格式化(带有颜色,而不是布局)带有类型注释(提示)的Python代码。对于以下代码,这样做失败:

from typing import Iterator

# return math.factorial(x)
def fib(n: int) -> Iterator[int]:
    a, b = 0, 1
    while a < n:
        yield a
        a, b = b, a + b        

"""
This function checks whether a string is a palindrome.
s - The string to check.
"""
def is_palindrome(s: str) -> bool:
    return s == s[::-1]

"""
This function compares two strings of word letters and returns the percentage match.

p_string1 - The first letters to compare.
p_string2 - The second letters to compare.
"""
def compare_letters(p_string1: str, p_string2: str) -> float:
    return 1.0

我正在使用,"python.formatting.provider": "black"但我也尝试过autopep8yapf通过在类型注释后将它们混合在一起,它们似乎都以相同的方式失败。

当我进入black网站并将代码粘贴到Black Playground时,它仍然可以正常工作。

我已经升级使用python -m pip install --upgrade black,它显示的版本与Black Playground(black-19.10b0)相同,所以不确定在哪里是Visual Studio Code问题或我问题。

我正在使用WinPython 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)] on win32

不太确定该如何通过这些lint,格式(颜色/布局),Python解析等来记录bug。

在Visual Studio Code中格式化Python类型注释是否成功,有人使用过什么设置?

更新:当我使用时,不会发生这种情况code --disable-extensions有谁知道我可以有选择地禁用扩展名以找出引起问题的扩展名吗?

超级英雄

卸载Python for VSCode扩展程序解决了该问题。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在VS Code中自动重新格式化Python代码

DB:Raw在postgres中不适用于日期格式

语法突出显示不适用于Visual Studio 2015 Update 3中的Node.js Vash视图文件

Visual Studio Code中的代码格式不适用于C#代码

是否有重新格式化python脚本的格式?

在Python中重新格式化DataFrame

分割后重新格式化python字符串

VS Code Intellisense不适用于Conda Python环境

VS Code TSX和返回后格式化

在PHP中从MySQL显示重新格式化的日期

VS Code 中的 Python

仅格式化<code>标签,带有pygments

Python Bokeh工具-如何从bokeh显示带有日期时间格式化程序xaxis的hovertool?

如何在JSTL中显示格式化的日历类型?

用于打印的Python字典键格式不适用于数字字符串

通过重新整理/重新格式化来删除注释中的多余空格

格式化标签不适用于Thymeleaf

使用Prettier格式化VS Code中的.ejs文件

为dart禁用VS Code中的自动格式化

intellij IDEA插件中的“ String @NotNull []”语法导致“'@NotNull'不适用于类型使用”

Python AutoPep8 格式不适用于最大行长参数

拆分时间格式对象不适用于 python 和 Pandas

Java 11(Zulu)中的DateTimeFormatter不适用于AM / PM格式

GCC和Clang printf格式检查不适用于模板函数中的decltype

十进制格式不适用于Java中的3位数字

在Android中以编程方式更改语言,不适用于从应用捆绑包格式生成的APK

条件格式不适用于 Google 表格中的“countif”功能

HashWithIndifferentAccess不适用于Rails 5中的%格式运算符

awk中的printf格式说明符不适用于多个参数