From 51a2cd12893c123aff64bd06204910fa74882912 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 27 Dec 2021 11:36:17 +0100 Subject: [PATCH] Enable stubtest for six (#6699) --- stubs/six/@tests/stubtest_allowlist.txt | 23 +++++++++++++++++++++++ stubs/six/METADATA.toml | 1 - stubs/six/six/__init__.pyi | 11 ++++++++--- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 stubs/six/@tests/stubtest_allowlist.txt diff --git a/stubs/six/@tests/stubtest_allowlist.txt b/stubs/six/@tests/stubtest_allowlist.txt new file mode 100644 index 000000000..d7158843a --- /dev/null +++ b/stubs/six/@tests/stubtest_allowlist.txt @@ -0,0 +1,23 @@ +# Problems inherited from the standard library +six.BytesIO.readlines +six.BytesIO.seek +six.StringIO.seek +six.StringIO.truncate +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 +six.get_function_globals +six.get_method_function +six.get_method_self +six.viewitems +six.viewkeys +six.viewvalues + +# Unclear problems +six.Iterator.__init__ +six.callable diff --git a/stubs/six/METADATA.toml b/stubs/six/METADATA.toml index 863ecee46..90e045694 100644 --- a/stubs/six/METADATA.toml +++ b/stubs/six/METADATA.toml @@ -1,3 +1,2 @@ version = "1.16.*" python2 = true -stubtest = false # TODO: figure out why this is needed diff --git a/stubs/six/six/__init__.pyi b/stubs/six/six/__init__.pyi index 1f36799d6..88590adae 100644 --- a/stubs/six/six/__init__.pyi +++ b/stubs/six/six/__init__.pyi @@ -1,10 +1,12 @@ from __future__ import print_function +import builtins import types import unittest 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 +from importlib.util import spec_from_loader as spec_from_loader from io import BytesIO as BytesIO, StringIO as StringIO from typing import Any, AnyStr, NoReturn, Pattern, Tuple, Type, TypeVar, overload from typing_extensions import Literal @@ -30,9 +32,12 @@ binary_type = bytes MAXSIZE: int -def callable(obj: object) -> bool: ... +callable = builtins.callable + def get_unbound_function(unbound: types.FunctionType) -> types.FunctionType: ... -def create_bound_method(func: types.FunctionType, obj: object) -> types.MethodType: ... + +create_bound_method = types.MethodType + def create_unbound_method(func: types.FunctionType, cls: type) -> types.FunctionType: ... Iterator = object @@ -87,7 +92,7 @@ def python_2_unicode_compatible(klass: _T) -> _T: ... class _LazyDescr: name: str def __init__(self, name: str) -> None: ... - def __get__(self, obj: object | None, type: Type[Any] | None = ...) -> Any: ... + def __get__(self, obj: object | None, tp: object) -> Any: ... class MovedModule(_LazyDescr): mod: str