【问题标题】:Unexpected type(s): (int, int) Possible type(s): (SupportsIndex, None) (slice, Iterable[None])意外的类型:(int, int) 可能的类型:(SupportsIndex, None) (slice, Iterable[None])
【发布时间】:2021-11-17 17:50:23
【问题描述】:

这段代码有什么问题:

split_list = [3600, 3600, 3600, 3600, 3600, 3600, 3600, 3600, 45]
split_list2 = [None, None, None, None, None, None, None, None, None, None, None, None]
result = [3600, 3600, 3600, 3600, 3600, 3600, 3600, 3600, 45, None, None, None]

for i in range(len(split_list)):
    split_list2[i] = split_list[i]

在 PyCharm 中它会发出警告;

意外类型:(int, int) 可能类型:(SupportsIndex, None) (slice, Iterable[None])

但是脚本运行得很好,这段代码完全符合我的预期。不过,我不喜欢 IDE 中的警告,有什么快速解决方法吗?

【问题讨论】:

    标签: python pycharm


    【解决方案1】:

    此警告已通过将 PyCharm 更新到 2021.2.2 来解决。

    这似乎是 IDE 的静态类型检查器早期版本中的一个错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-17
      • 2020-11-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多