Skip to content

narrow signature of __contains__ for str-like classes #2967

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

Merged
merged 3 commits into from
May 7, 2019
Merged
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
12 changes: 8 additions & 4 deletions stdlib/2/__builtin__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,8 @@ else:
def __ge__(self, x: unicode) -> bool: ...

def __len__(self) -> int: ...
def __contains__(self, s: object) -> bool: ...
# The argument type is incompatible with Sequence
def __contains__(self, s: Union[unicode, bytes]) -> bool: ... # type: ignore
def __iter__(self) -> Iterator[unicode]: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
Expand Down Expand Up @@ -520,7 +521,8 @@ class str(Sequence[str], _str_base):
def __add__(self, s: str) -> str: ...
else:
def __add__(self, s: AnyStr) -> AnyStr: ...
def __contains__(self, o: object) -> bool: ...
# Incompatible with Sequence.__contains__
def __contains__(self, o: Union[str, Text]) -> bool: ... # type: ignore
def __eq__(self, x: object) -> bool: ...
def __ge__(self, x: Text) -> bool: ...
def __getitem__(self, i: Union[int, slice]) -> str: ...
Expand Down Expand Up @@ -622,7 +624,8 @@ if sys.version_info >= (3,):
def __rmul__(self, n: int) -> bytes: ...
if sys.version_info >= (3, 5):
def __mod__(self, value: Any) -> bytes: ...
def __contains__(self, o: object) -> bool: ...
# Incompatible with Sequence.__contains__
def __contains__(self, o: Union[int, bytes]) -> bool: ... # type: ignore
def __eq__(self, x: object) -> bool: ...
def __ne__(self, x: object) -> bool: ...
def __lt__(self, x: bytes) -> bool: ...
Expand Down Expand Up @@ -754,7 +757,8 @@ class bytearray(MutableSequence[int], ByteString):
def __imul__(self, n: int) -> bytearray: ...
if sys.version_info >= (3, 5):
def __mod__(self, value: Any) -> bytes: ...
def __contains__(self, o: object) -> bool: ...
# Incompatible with Sequence.__contains__
def __contains__(self, o: Union[int, bytes]) -> bool: ... # type: ignore
def __eq__(self, x: object) -> bool: ...
def __ne__(self, x: object) -> bool: ...
def __lt__(self, x: bytes) -> bool: ...
Expand Down
12 changes: 8 additions & 4 deletions stdlib/2and3/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,8 @@ else:
def __ge__(self, x: unicode) -> bool: ...

def __len__(self) -> int: ...
def __contains__(self, s: object) -> bool: ...
# The argument type is incompatible with Sequence
def __contains__(self, s: Union[unicode, bytes]) -> bool: ... # type: ignore
def __iter__(self) -> Iterator[unicode]: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
Expand Down Expand Up @@ -520,7 +521,8 @@ class str(Sequence[str], _str_base):
def __add__(self, s: str) -> str: ...
else:
def __add__(self, s: AnyStr) -> AnyStr: ...
def __contains__(self, o: object) -> bool: ...
# Incompatible with Sequence.__contains__
def __contains__(self, o: Union[str, Text]) -> bool: ... # type: ignore
def __eq__(self, x: object) -> bool: ...
def __ge__(self, x: Text) -> bool: ...
def __getitem__(self, i: Union[int, slice]) -> str: ...
Expand Down Expand Up @@ -622,7 +624,8 @@ if sys.version_info >= (3,):
def __rmul__(self, n: int) -> bytes: ...
if sys.version_info >= (3, 5):
def __mod__(self, value: Any) -> bytes: ...
def __contains__(self, o: object) -> bool: ...
# Incompatible with Sequence.__contains__
def __contains__(self, o: Union[int, bytes]) -> bool: ... # type: ignore
def __eq__(self, x: object) -> bool: ...
def __ne__(self, x: object) -> bool: ...
def __lt__(self, x: bytes) -> bool: ...
Expand Down Expand Up @@ -754,7 +757,8 @@ class bytearray(MutableSequence[int], ByteString):
def __imul__(self, n: int) -> bytearray: ...
if sys.version_info >= (3, 5):
def __mod__(self, value: Any) -> bytes: ...
def __contains__(self, o: object) -> bool: ...
# Incompatible with Sequence.__contains__
def __contains__(self, o: Union[int, bytes]) -> bool: ... # type: ignore
def __eq__(self, x: object) -> bool: ...
def __ne__(self, x: object) -> bool: ...
def __lt__(self, x: bytes) -> bool: ...
Expand Down