diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/bytestring_usage.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/bytestring_usage.rs index fec031165b..a0c52bc12b 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/bytestring_usage.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/bytestring_usage.rs @@ -20,11 +20,23 @@ use crate::{FixAvailability, Violation}; /// from typing import ByteString /// ``` /// -/// Use instead: +/// On Python versions after 3.12, use the `Buffer` type from the standard library instead: /// ```python /// from collections.abc import Buffer /// ``` /// +/// For earlier Python versions, you can use `typing_extensions`: +/// ```python +/// from typing_extensions import Buffer +/// ``` +/// +/// or a union: +/// ```python +/// from typing import Union +/// +/// x: Union[bytes, bytearray, memoryview] +/// ``` +/// /// ## References /// - [Python documentation: The `ByteString` type](https://docs.python.org/3/library/typing.html#typing.ByteString) #[derive(ViolationMetadata)]