gh-91896: Improve visibility of ByteString deprecation warnings#104294
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#102096 added deprecation warnings for
collections.abc.ByteString, but these warnings are currently only emitted on subclassingByteStringor callingisinstance()against it. ImportingByteStringor accessing it viaimport collections.abc; collections.abc.ByteStringdoes not currently trigger any warnings, meaning somebody who's just using the class for type annotations might not get any warning that the class will be removed in 3.14. Moreover, theisinstance()deprecation warnings are only emitted onisinstance()checks againstcollections.abc.ByteString, not onisinstance()checks againsttyping.ByteString. The docs update that we just made in 1f56795 says thattyping.ByteStringwill also be removed in Python 3.14, so we should emit the same deprecation warnings fortyping.ByteString.This PR adds deprecation warnings for:
from collections.abc import ByteStringimport collections.abc; collections.abc.ByteStringfrom typing import ByteStringimport typing; typing.ByteStringisinstance(b"", typing.ByteString)