Python打字提示亚型

发布于 2025-02-08 18:44:54 字数 259 浏览 2 评论 0原文

我有一个类型的对象dict [str,Union [str [str,dict [str,str]]],该>正在将其附加到类型list的Python列表中联合[str,dict [str,可选[Union [str,bool]]]]]]。 Mypy为此引起了错误。

我意识到这是Mypy不接受str作为可选[Union [str,bool]]的一部分。有解决方法吗?

I have an object of the type Dict[str, Union[str, Dict[str, str]]], which is being appended into a Python list of type List[Dict[str, Union[str, Dict[str, Optional[Union[str, bool]]]]]]. Mypy raises an error for this.

I realize that this is Mypy not accepting str as being part of Optional[Union[str, bool]]. Is there some workaround to this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文