【发布时间】:2018-09-07 18:22:00
【问题描述】:
我正在使用石墨烯和 mypy 的静态类型检查来构建 graphQL 模式。 架构的代码如下所示:
from typing import Dict, List, NamedTuple, Union
import graphene
class PossibleAnswer(graphene.ObjectType):
"""Object representing single possible answer, a pair of key and text."""
paId = graphene.String(
description="Answer id, automatically generated sequence number.")
text = graphene.String(description="Answer text, in requested language")
当我使用 --ignore-missing-imports --strict 选项运行 mypy 检查时,我收到错误:
error: Class cannot subclass 'ObjectType' (has type 'Any')
我找到了解决方法put a # type: ignore to silence the error,但我需要解决这个问题,而不是静音。更改 mypy 选项不是一种选择。
我如何告诉 mypy 这是石墨烯类型,而不是我正在创建的对象的 Any 类型?
【问题讨论】:
标签: python-3.x mypy graphene-python