Sup*_*ero 6 python python-3.x visual-studio-code
我试图让 Visual Studio Code 使用类型注释(提示)格式化(颜色而不是布局)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
Run Code Online (Sandbox Code Playgroud)
我正在使用,"python.formatting.provider": "black"
但我也尝试过autopep8
和yapf
。它们似乎都以同样的方式失败,在类型注释之后将它们全部混淆。
当我访问该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
.
不太确定使用所有这些 linting、格式(颜色/布局)、Python 解析等来记录错误。
有没有人在 Visual Studio Code 中格式化 Python 类型注释方面取得过任何成功,您使用的是什么设置?
更新:当我使用code --disable-extensions
. 有谁知道我如何有选择地禁用扩展以找出导致问题的原因?
Sup*_*ero 52
卸载Python for VSCode
扩展解决了这个问题。
归档时间: |
|
查看次数: |
6043 次 |
最近记录: |