Skip to content
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
1 change: 0 additions & 1 deletion stdlib/2/functools.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from abc import ABCMeta, abstractmethod
from typing import Any, Callable, Generic, Dict, Iterable, Optional, Sequence, Tuple, TypeVar, overload
from collections import namedtuple

_AnyCallable = Callable[..., Any]

Expand Down
65 changes: 31 additions & 34 deletions stdlib/2/inspect.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ CO_VARARGS: int
CO_VARKEYWORDS: int
TPFLAGS_IS_ABSTRACT: int

ModuleInfo = NamedTuple('ModuleInfo', [('name', str),
('suffix', str),
('mode', str),
('module_type', int),
])
class ModuleInfo(NamedTuple):
name: str
suffix: str
mode: str
module_type: int

def getmembers(
object: object,
predicate: Optional[Callable[[Any], bool]] = ...
Expand Down Expand Up @@ -70,22 +71,22 @@ def indentsize(line: str) -> int: ...
# Classes and functions
def getclasstree(classes: List[type], unique: bool = ...) -> List[Union[Tuple[type, Tuple[type, ...]], List[Any]]]: ...

ArgSpec = NamedTuple('ArgSpec', [('args', List[str]),
('varargs', Optional[str]),
('keywords', Optional[str]),
('defaults', Tuple[Any, ...]),
])
class ArgSpec(NamedTuple):
args: List[str]
varargs: Optional[str]
keywords: Optional[str]
defaults: Tuple[Any, ...]

ArgInfo = NamedTuple('ArgInfo', [('args', List[str]),
('varargs', Optional[str]),
('keywords', Optional[str]),
('locals', Dict[str, Any]),
])
class ArgInfo(NamedTuple):
args: List[str]
varargs: Optional[str]
keywords: Optional[str]
locals: Dict[str, Any]

Arguments = NamedTuple('Arguments', [('args', List[Union[str, List[Any]]]),
('varargs', Optional[str]),
('keywords', Optional[str]),
])
class Arguments(NamedTuple):
args: List[Union[str, List[Any]]]
varargs: Optional[str]
keywords: Optional[str]

def getargs(co: CodeType) -> Arguments: ...
def getargspec(func: object) -> ArgSpec: ...
Expand All @@ -101,16 +102,12 @@ def getcallargs(func, *args, **kwds) -> Dict[str, Any]: ...

# The interpreter stack

Traceback = NamedTuple(
'Traceback',
[
('filename', str),
('lineno', int),
('function', str),
('code_context', Optional[List[str]]),
('index', Optional[int]),
]
)
class Traceback(NamedTuple):
filename: str
lineno: int
function: str
code_context: Optional[List[str]]
index: Optional[int] # type: ignore

_FrameInfo = Tuple[FrameType, str, int, str, Optional[List[str]], Optional[int]]

Expand All @@ -123,10 +120,10 @@ def currentframe(depth: int = ...) -> FrameType: ...
def stack(context: int = ...) -> List[_FrameInfo]: ...
def trace(context: int = ...) -> List[_FrameInfo]: ...

Attribute = NamedTuple('Attribute', [('name', str),
('kind', str),
('defining_class', type),
('object', object),
])
class Attribute(NamedTuple):
name: str
kind: str
defining_class: type
object: object

def classify_class_attrs(cls: type) -> List[Attribute]: ...
32 changes: 11 additions & 21 deletions stdlib/2/os/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,17 @@ if sys.version_info >= (3, 6):

_PathType = path._PathType

_StatVFS = NamedTuple('_StatVFS', [('f_bsize', int), ('f_frsize', int), ('f_blocks', int),
('f_bfree', int), ('f_bavail', int), ('f_files', int),
('f_ffree', int), ('f_favail', int), ('f_flag', int),
('f_namemax', int)])
class _StatVFS(NamedTuple):
f_bsize: int
f_frsize: int
f_blocks: int
f_bfree: int
f_bavail: int
f_files: int
f_ffree: int
f_favail: int
f_flag: int
f_namemax: int

def getlogin() -> str: ...
def getpid() -> int: ...
Expand Down Expand Up @@ -349,20 +356,3 @@ if sys.version_info < (3, 0):
P_ALL: int
WEXITED: int
WNOWAIT: int

if sys.version_info >= (3, 3):
Comment thread
srittau marked this conversation as resolved.
if sys.platform != 'win32':
# Unix only
def sync() -> None: ...

def truncate(path: Union[_PathType, int], length: int) -> None: ... # Unix only up to version 3.4

def fwalk(top: AnyStr = ..., topdown: bool = ...,
onerror: Callable = ..., *, follow_symlinks: bool = ...,
dir_fd: int = ...) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr], int]]: ...

terminal_size = NamedTuple('terminal_size', [('columns', int), ('lines', int)])
def get_terminal_size(fd: int = ...) -> terminal_size: ...

if sys.version_info >= (3, 4):
def cpu_count() -> Optional[int]: ...
24 changes: 18 additions & 6 deletions stdlib/2/resource.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,24 @@ RLIMIT_MEMLOCK: int
RLIMIT_VMEM: int
RLIMIT_AS: int

_RUsage = NamedTuple('_RUsage', [('ru_utime', float), ('ru_stime', float), ('ru_maxrss', int),
('ru_ixrss', int), ('ru_idrss', int), ('ru_isrss', int),
('ru_minflt', int), ('ru_majflt', int), ('ru_nswap', int),
('ru_inblock', int), ('ru_oublock', int), ('ru_msgsnd', int),
('ru_msgrcv', int), ('ru_nsignals', int), ('ru_nvcsw', int),
('ru_nivcsw', int)])
class _RUsage(NamedTuple):
ru_utime: float
ru_stime: float
ru_maxrss: int
ru_ixrss: int
ru_idrss: int
ru_isrss: int
ru_minflt: int
ru_majflt: int
ru_nswap: int
ru_inblock: int
ru_oublock: int
ru_msgsnd: int
ru_msgrcv: int
ru_nsignals: int
ru_nvcsw: int
ru_nivcsw: int

def getrusage(who: int) -> _RUsage: ...
def getpagesize() -> int: ...

Expand Down
19 changes: 10 additions & 9 deletions stdlib/2/spwd.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from typing import List, NamedTuple

struct_spwd = NamedTuple("struct_spwd", [("sp_nam", str),
("sp_pwd", str),
("sp_lstchg", int),
("sp_min", int),
("sp_max", int),
("sp_warn", int),
("sp_inact", int),
("sp_expire", int),
("sp_flag", int)])
class struct_spwd(NamedTuple):
sp_nam: str
sp_pwd: str
sp_lstchg: int
sp_min: int
sp_max: int
sp_warn: int
sp_inact: int
sp_expire: int
sp_flag: int

def getspall() -> List[struct_spwd]: ...
def getspnam(name: str) -> struct_spwd: ...
34 changes: 15 additions & 19 deletions stdlib/2/urlparse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,23 @@ class ResultMixin(object):
@property
def port(self) -> Optional[int]: ...

class SplitResult(
NamedTuple(
'SplitResult',
[
('scheme', str), ('netloc', str), ('path', str), ('query', str), ('fragment', str)
]
),
ResultMixin
):
class _SplitResult(NamedTuple):
scheme: str
netloc: str
path: str
query: str
fragment: str
class SplitResult(_SplitResult, ResultMixin):
def geturl(self) -> str: ...

class ParseResult(
NamedTuple(
'ParseResult',
[
('scheme', str), ('netloc', str), ('path', str), ('params', str), ('query', str),
('fragment', str)
]
),
ResultMixin
):
class _ParseResult(NamedTuple):
scheme: str
netloc: str
path: str
params: str
query: str
fragment: str
class ParseResult(_ParseResult, ResultMixin):
def geturl(self) -> str: ...

def urlparse(url: _String, scheme: _String = ...,
Expand Down
5 changes: 4 additions & 1 deletion stdlib/2and3/_curses.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -454,5 +454,8 @@ class _CursesWindow:
def vline(self, y: int, x: int, ch: _chtype, n: int) -> None: ...

if sys.version_info >= (3, 8):
_ncurses_version = NamedTuple("ncurses_version", [("major", int), ("minor", int), ("patch", int)])
class _ncurses_version(NamedTuple):
major: int
minor: int
patch: int
ncurses_version: _ncurses_version
10 changes: 7 additions & 3 deletions stdlib/2and3/aifc.pyi
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@

from typing import Union, IO, Optional, Type, NamedTuple, List, Tuple, Any, Text, overload
from typing_extensions import Literal
from types import TracebackType
import sys

class Error(Exception): ...

_aifc_params = NamedTuple('_aifc_params', [('nchannels', int), ('sampwidth', int), ('framerate', int),
('nframes', int), ('comptype', bytes), ('compname', bytes)])
class _aifc_params(NamedTuple):
nchannels: int
sampwidth: int
framerate: int
nframes: int
comptype: bytes
compname: bytes

_File = Union[Text, IO[bytes]]
_Marker = Tuple[int, int, bytes]
Expand Down
3 changes: 1 addition & 2 deletions stdlib/2and3/crypt.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import sys
from typing import List, NamedTuple, Optional, Union

from typing import List, Optional, Union

if sys.version_info >= (3, 3):
class _Method: ...
Expand Down
8 changes: 4 additions & 4 deletions stdlib/2and3/decimal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ else:
_ComparableNum = Union[Decimal, float]
_DecimalT = TypeVar('_DecimalT', bound=Decimal)

DecimalTuple = NamedTuple('DecimalTuple',
[('sign', int),
('digits', Tuple[int, ...]),
('exponent', int)])
class DecimalTuple(NamedTuple):
sign: int
digits: Tuple[int, ...]
exponent: int

ROUND_DOWN: str
ROUND_HALF_UP: str
Expand Down
9 changes: 4 additions & 5 deletions stdlib/2and3/difflib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ else:

_JunkCallback = Union[Callable[[Text], bool], Callable[[str], bool]]

Match = NamedTuple('Match', [
('a', int),
('b', int),
('size', int),
])
class Match(NamedTuple):
a: int
b: int
size: int

class SequenceMatcher(Generic[_T]):
def __init__(self, isjunk: Optional[Callable[[_T], bool]] = ...,
Expand Down
22 changes: 9 additions & 13 deletions stdlib/2and3/dis.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,15 @@ _have_code_or_string = Union[_have_code, str, bytes]


if sys.version_info >= (3, 4):
Instruction = NamedTuple(
"Instruction",
[
('opname', str),
('opcode', int),
('arg', Optional[int]),
('argval', Any),
('argrepr', str),
('offset', int),
('starts_line', Optional[int]),
('is_jump_target', bool)
]
)
class Instruction(NamedTuple):
opname: str
opcode: int
arg: Optional[int]
argval: Any
argrepr: str
offset: int
starts_line: Optional[int]
is_jump_target: bool

class Bytecode:
codeobj: types.CodeType
Expand Down
7 changes: 3 additions & 4 deletions stdlib/2and3/doctest.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import sys
import types
import unittest

TestResults = NamedTuple('TestResults', [
('failed', int),
('attempted', int),
])
class TestResults(NamedTuple):
failed: int
attempted: int

OPTIONFLAGS_BY_NAME: Dict[str, int]
def register_optionflag(name: str) -> int: ...
Expand Down
9 changes: 5 additions & 4 deletions stdlib/2and3/grp.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from typing import List, NamedTuple, Optional

struct_group = NamedTuple("struct_group", [("gr_name", str),
("gr_passwd", Optional[str]),
("gr_gid", int),
("gr_mem", List[str])])
class struct_group(NamedTuple):
gr_name: str
gr_passwd: Optional[str]
gr_gid: int
gr_mem: List[str]

def getgrall() -> List[struct_group]: ...
def getgrgid(gid: int) -> struct_group: ...
Expand Down
5 changes: 4 additions & 1 deletion stdlib/2and3/pkgutil.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ else:
Loader = Any

if sys.version_info >= (3, 6):
ModuleInfo = NamedTuple('ModuleInfo', [('module_finder', Any), ('name', str), ('ispkg', bool)])
class ModuleInfo(NamedTuple):
module_finder: Any
name: str
ispkg: bool
_YMFNI = Generator[ModuleInfo, None, None]
else:
_YMFNI = Generator[Tuple[Any, str, bool], None, None]
Expand Down
Loading