【发布时间】:2019-05-21 15:18:13
【问题描述】:
我正在尝试 Python 3.7 中的 dataclasses 功能,但在单词“hue”下方收到此警告:
'hue' used before definition
Python (use-before-def)
我想这是一个 linter 警告。我尝试了几个 python 扩展提供的 linter,但它们都不起作用。
from dataclasses import dataclass
@dataclass
class Color:
hue: int
lightness: float = 2.0
c = Color(2)
有没有办法启用语法检查等但避免收到此警告?
使用 pep8 发出警告
使用 pylint 或 mypy 发出警告
【问题讨论】:
-
您能否提供导致此错误的各种工具的版本号?你确定它们都更新到最新版本了吗?
-
Python扩展版本为2018.12.1
标签: python python-3.x visual-studio-code python-dataclasses