python - Typehint 在 python mypy 中添加列表,其中列表具有不同的结构
问题描述
例子:
# check.py
x = [("a", "b"), ("c", "d")]
y = [("x", [("1", "2"), ("3", "4")])]
z = x + y
返回mypy check.py
:
check.py:5: error: Unsupported operand types for + ("List[Tuple[str, str]]" and "List[Tuple[str, List[Tuple[str, str]]]]") [operator]
Found 1 error in 1 file (checked 1 source file)
我知道这个添加虽然有效 - 我不明白为什么它是“不支持的”,或者我应该怎么做才能输入这个。
解决方案
推荐阅读
- amazon-web-services - AWS.EC2.Windows.CloudWatch.json 未记录可用磁盘空间
- sql - SQL-在数据库中查找丢失成绩的学生
- google-chrome - 如何处理从 Chrome 80 开始的新的第三方 cookie 规则?
- xml - 如何在 XSLT3.0 中将空行从 xml 删除到 CSV 输出
- c - 在C中使用队列反转堆栈
- javascript - 如何使用 Observable 启动下一个异步任务
- python - 23.2 项目 2:使用 LOOPS 进行数据可视化
- go - 使用 GORM 和 echo-framework 进行更新的惯用方式
- apache-kafka - Kafka 的消费者线程数应该等于主题分区数
- reactjs - react-router-dom history.goBack() 在 Firefox 和 Safari 上不起作用