【发布时间】:2021-03-02 17:03:58
【问题描述】:
我在 Python 中使用包 pydantic 和链接器 Flake8。我想将 pydantic 的 constr 与常规的 Experssion 一起使用。只应传递某些字符。 (a-z、A-Z、0-9 和 _)
常规的 Experssion "^[a-zA-Z0-9_]*$" 有效,但 flake8 显示以下错误:
前向注释中的语法错误 '^[a-zA-Z0-9_]*$' flake8(F722)
class RedisSettings(BaseModel):
keyInput: constr(regex="^[a-zA-Z0-9_]*$") = ""
keyOutput: constr(regex="^[a-zA-Z0-9_]*$") = ""
你能帮我避免错误信息吗?
【问题讨论】: