跳到内容

byte-string-usage (PYI057)(字节串使用)

源自 flake8-pyi 代码检查器。

作用

检查 typing.ByteStringcollections.abc.ByteString 的使用。

为什么这不好?

ByteString 自 Python 3.9 起已被弃用,将在 Python 3.14 中移除。Python 文档建议使用 collections.abc.Buffer(或 Python \<3.12 上的 typing_extensions 反向移植)或类似 bytes | bytearray | memoryview 的联合类型来替代。

示例

from typing import ByteString

建议改为

from collections.abc import Buffer

参考