Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add __new__ to str and int stubs in both Pythons. #1352

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
Jun 13, 2017
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
13 changes: 9 additions & 4 deletions stdlib/2/__builtin__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,15 @@ class type(object):

class int(SupportsInt, SupportsFloat, SupportsAbs[int]):
@overload
def __init__(self) -> None: ...
def __init__(self, x: SupportsInt = ...) -> None: ...
@overload
def __init__(self, x: Union[str, unicode, bytearray], base: int = ...) -> None: ...

@overload
def __init__(self, x: SupportsInt) -> None: ...
def __new__(cls: Type[_T1], x: SupportsInt = ...) -> _T1: ...
@overload
def __init__(self, x: Union[str, unicode, bytearray], base: int = 10) -> None: ...
def __new__(cls: Type[_T1], x: Union[str, unicode, bytearray], base: int = ...) -> _T1: ...

def bit_length(self) -> int: ...

def __add__(self, x: int) -> int: ...
Expand Down Expand Up @@ -309,7 +313,8 @@ class unicode(basestring, Sequence[unicode]):
def __hash__(self) -> int: ...

class str(basestring, Sequence[str]):
def __init__(self, object: object='') -> None: ...
def __init__(self, object: object = ...) -> None: ...
def __new__(cls: Type[_T1], object: object = ...) -> _T1: ...
def capitalize(self) -> str: ...
def center(self, width: int, fillchar: str = ...) -> str: ...
def count(self, x: unicode, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
Expand Down
5 changes: 4 additions & 1 deletion stdlib/3.4/enum.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ class Enum(metaclass=EnumMeta):
name = ... # type: str
value = ... # type: Any

class IntEnum(int, Enum):
_T1 = TypeVar('_T1')

class IntEnum(int, Enum): # type: ignore
value = ... # type: int
def __new__(cls: Type[_T1], value: Any) -> _T1: ...

def unique(enumeration: _S) -> _S: ...

Expand Down
21 changes: 17 additions & 4 deletions stdlib/3/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,16 @@ class super:
def __init__(self) -> None: ...

class int(SupportsInt, SupportsFloat, SupportsAbs[int]):
def __init__(self, x: Union[SupportsInt, str, bytes] = ..., base: int = ...) -> None: ...
@overload
def __init__(self, x: SupportsInt = ...) -> None: ...
@overload
def __init__(self, x: Union[str, bytes], base: int = ...) -> None: ...

@overload
def __new__(cls: Type[_T1], x: SupportsInt = ...) -> _T1: ...
@overload
def __new__(cls: Type[_T1], x: Union[str, bytes], base: int = ...) -> _T1: ...

def bit_length(self) -> int: ...
def to_bytes(self, length: int, byteorder: str, *, signed: bool = ...) -> bytes: ...
@classmethod
Expand Down Expand Up @@ -227,11 +236,15 @@ class complex(SupportsAbs[float]):

class str(Sequence[str]):
@overload
def __init__(self) -> None: ...
def __init__(self, o: object = ...) -> None: ...
@overload
def __init__(self, o: object) -> None: ...
def __init__(self, o: bytes, encoding: str = ..., errors: str = ...) -> None: ...

@overload
def __new__(cls: Type[_T1], o: object = ...) -> _T1: ...
@overload
def __init__(self, o: bytes, encoding: str = ..., errors: str = 'strict') -> None: ...
def __new__(cls: Type[_T1], o: bytes, encoding: str = ..., errors: str = ...) -> _T1: ...

def capitalize(self) -> str: ...
def casefold(self) -> str: ...
def center(self, width: int, fillchar: str = ' ') -> str: ...
Expand Down
7 changes: 4 additions & 3 deletions third_party/2/enum.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Any, TypeVar
from typing import List, Any, TypeVar, Type

class Enum:
def __new__(cls, value: Any) -> None: ...
Expand All @@ -12,8 +12,9 @@ class Enum:
name = ... # type: str
value = ... # type: Any

class IntEnum(int, Enum): ...

_T = TypeVar('_T')

class IntEnum(int, Enum): # type: ignore
def __new__(cls: Type[_T], value: Any) -> _T: ...

def unique(enumeration: _T) -> _T: ...