用VsCode编辑代码,flake8并无报错,运行也正常。但是把代码文件保存到桌面文件夹里,再重新打开,就flake8就提示很多错误,但是代码也能正常运行。
from enum import Enum
class Direction(Enum):
LONG = "buy"
SHORT = "sell"
order_direction = Direction.LONG
class Offset(Enum):
OPEN = "on"
CLOSE = "off"
CLOSE_TODAY = "off_today"
CLOSE_YESTERDAY = "off_yestoday"
def send_order(
vt_symbol: str,
price: float,
volume: int,
direction: Direction,
offset: Offset
) -> str:
pass
class TradeData:
vt_symbol: str = "",
price: float = 0.0,
volume: int = 0,
direction: Direction = None,
offset: Offset = None
direction = Direction.LONG
print(direction)
direction_value = direction.value
print(direction_value)
卸载VsCode重新安装,
代码的缩进都按规范来的,代码没有问题。但是flake8的提示肯定是有问题的,如何解决?
试试在定义函数,的上面在加一个空行,
语法规定希望隔两个空行,你却只有一个