Skip to content

Do not recommend use of collections.abc.ByteString #350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## Unreleased

* Y027: No longer recommend replacing `typing.ByteString` with
`collections.abc.ByteString`, since their semantics do not correspond
and `collections.abc.ByteString`'s semantics are terrible to begin with.

## 23.1.2

* Y011/Y014/Y015: Increase the maximum character length of literal numbers
Expand Down
2 changes: 1 addition & 1 deletion pyi.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ class TypeVarInfo(NamedTuple):
),
# typing aliases for collections.abc
# typing.AbstractSet is deliberately omitted (special-cased elsewhere)
# typing.ByteString is also deliberately omitted (https://github.com/python/cpython/issues/102092)
# If the second element of the tuple is `None`, it signals that the object shouldn't be parameterized
"typing.ByteString": ("collections.abc.ByteString", None),
"typing.Collection": ("collections.abc.Collection", "T"),
"typing.ItemsView": ("collections.abc.ItemsView", _MAPPING_SLICE),
"typing.KeysView": ("collections.abc.KeysView", "KeyType"),
Expand Down
2 changes: 1 addition & 1 deletion tests/imports.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ from collections.abc import (
MutableSequence,
ByteString
)
from typing import ByteString
from re import Match, Pattern
# Things that are of no use for stub files are intentionally omitted.
from typing import (
Expand Down Expand Up @@ -93,7 +94,6 @@ from typing import ContextManager # Y022 Use "contextlib.AbstractContextManager
from typing import OrderedDict # Y022 Use "collections.OrderedDict[KeyType, ValueType]" instead of "typing.OrderedDict[KeyType, ValueType]" (PEP 585 syntax)
from typing_extensions import OrderedDict # Y022 Use "collections.OrderedDict[KeyType, ValueType]" instead of "typing_extensions.OrderedDict[KeyType, ValueType]" (PEP 585 syntax)
from typing import Callable # Y022 Use "collections.abc.Callable" instead of "typing.Callable" (PEP 585 syntax)
from typing import ByteString # Y022 Use "collections.abc.ByteString" instead of "typing.ByteString" (PEP 585 syntax)
from typing import Container # Y022 Use "collections.abc.Container[T]" instead of "typing.Container[T]" (PEP 585 syntax)
from typing import Hashable # Y022 Use "collections.abc.Hashable" instead of "typing.Hashable" (PEP 585 syntax)
from typing import ItemsView # Y022 Use "collections.abc.ItemsView[KeyType, ValueType]" instead of "typing.ItemsView[KeyType, ValueType]" (PEP 585 syntax)
Expand Down