提问人:songofhawk 提问时间:9/26/2023 最后编辑:Goku - stands with Palestinesongofhawk 更新时间:9/26/2023 访问量:58
意外类型:(int, bytes) 可能的类型:(SupportsIndex, SupportsIndex) (slice, Iterable[SupportsIndex] | bytes)
Unexpected type(s): (int, bytes) Possible type(s): (SupportsIndex, SupportsIndex) (slice, Iterable[SupportsIndex] | bytes)
问:
当我在下面写一个python功能时:
def readinto(self, b: bytearray) -> int:
n, size = 0, len(b)
while n < size:
try:
b[n] = next(self._it)
except StopIteration:
break
n += 1
return n
我从 IDE 的 b[n] 上得到了一个减弱,它说:
意外类型:(int, bytes) 可能的类型:(SupportsIndex、 SupportsIndex) (slice, Iterable[SupportsIndex] | 字节)
我完全困惑:为什么数组 b 的索引应该是 SupportsIndex 的一种类型?简单的int有什么问题吗?
答:
1赞
Goku - stands with Palestine
9/26/2023
#1
显然这是 Pycharm 中的一个错误:
它存在于和其他版本中2021.2.3
PyCharm 2022.1
没有这个错误。
但是,从 2023.2.1(社区版)开始,该错误似乎又回来了
请尝试以下解决方法(临时解决方案):
转到
File -> Manage IDE Settings -> Restore Default Settings
或
Disable warnings/ ignore warnings
评论
0赞
songofhawk
9/26/2023
所以这是一个错误,哈哈。好的,那我将为它创建一个问题并等待它被修复。
0赞
Goku - stands with Palestine
9/26/2023
@songofhawk祝你好运:)
评论