Improve accuracy of six byte index methods (#9117)

This commit is contained in:
Samuel T
2022-11-09 22:22:33 -05:00
committed by GitHub
parent 0ac98f6b80
commit 796bdc2eb0
6 changed files with 41 additions and 20 deletions

View File

@@ -8,8 +8,6 @@ six.create_bound_method.__defaults__
six.moves.*
# Implemented using "operator" functions in the implementation
six.byte2int
six.indexbytes
six.get_function_closure
six.get_function_code
six.get_function_defaults
@@ -19,6 +17,8 @@ six.get_method_self
six.viewitems
six.viewkeys
six.viewvalues
# Should be `operator.itemgetter[int]`. But a bug in mypy prevents using TypeVar in itemgetter__call__
six.byte2int
# Unclear problems
six.callable

View File

@@ -1,7 +1,8 @@
import builtins
import operator
import types
import unittest
from _typeshed import IdentityFunction
from _typeshed import IdentityFunction, SupportsGetItem
from builtins import next as next
from collections.abc import Callable, ItemsView, Iterable, Iterator as _Iterator, KeysView, Mapping, ValuesView
from functools import wraps as wraps
@@ -11,7 +12,7 @@ from re import Pattern
from typing import Any, AnyStr, NoReturn, TypeVar, overload
from typing_extensions import Literal
from . import moves as moves
from six import moves as moves
_T = TypeVar("_T")
_K = TypeVar("_K")
@@ -63,9 +64,13 @@ def u(s: str) -> str: ...
unichr = chr
def int2byte(i: int) -> bytes: ...
def byte2int(bs: bytes) -> int: ...
def indexbytes(buf: bytes, i: int) -> int: ...
def iterbytes(buf: bytes) -> _Iterator[int]: ...
# Should be `byte2int: operator.itemgetter[int]`. But a bug in mypy prevents using TypeVar in itemgetter__call__
def byte2int(obj: SupportsGetItem[int, _T]) -> _T: ...
indexbytes = operator.getitem
iterbytes = iter
def assertCountEqual(self: unittest.TestCase, first: Iterable[_T], second: Iterable[_T], msg: str | None = ...) -> None: ...
@overload
def assertRaisesRegex(self: unittest.TestCase, msg: str | None = ...) -> Any: ...