Convert namedtuples to class syntax (#3321)

This commit is contained in:
Sebastian Rittau
2019-10-20 10:37:33 +02:00
committed by GitHub
parent 2b9dc7b9c2
commit ec7960a8cb
41 changed files with 397 additions and 383 deletions

View File

@@ -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]

View File

@@ -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]] = ...
@@ -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: ...
@@ -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]]
@@ -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]: ...

View File

@@ -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: ...
@@ -349,20 +356,3 @@ if sys.version_info < (3, 0):
P_ALL: int
WEXITED: int
WNOWAIT: int
if sys.version_info >= (3, 3):
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]: ...

View File

@@ -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: ...

View File

@@ -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: ...

View File

@@ -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 = ...,

View File

@@ -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

View File

@@ -1,4 +1,3 @@
from typing import Union, IO, Optional, Type, NamedTuple, List, Tuple, Any, Text, overload
from typing_extensions import Literal
from types import TracebackType
@@ -6,8 +5,13 @@ 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]

View File

@@ -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: ...

View File

@@ -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

View File

@@ -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]] = ...,

View File

@@ -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

View File

@@ -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: ...

View File

@@ -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: ...

View File

@@ -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]

View File

@@ -1,13 +1,12 @@
import sys
from typing import Any, Callable, Dict, List, NamedTuple, Optional, Text, Tuple
Event = NamedTuple('Event', [
('time', float),
('priority', Any),
('action', Callable[..., Any]),
('argument', Tuple[Any, ...]),
('kwargs', Dict[Text, Any]),
])
class Event(NamedTuple):
time: float
priority: Any
action: Callable[..., Any]
argument: Tuple[Any, ...]
kwargs: Dict[Text, Any]
class scheduler:
if sys.version_info >= (3, 3):

View File

@@ -114,9 +114,10 @@ else:
def move(src: _Path, dst: _Path) -> _PathReturn: ...
if sys.version_info >= (3,):
_ntuple_diskusage = NamedTuple('usage', [('total', int),
('used', int),
('free', int)])
class _ntuple_diskusage(NamedTuple):
total: int
used: int
free: int
def disk_usage(path: _Path) -> _ntuple_diskusage: ...
def chown(path: _Path, user: Optional[str] = ...,
group: Optional[str] = ...) -> None: ...

View File

@@ -5,13 +5,12 @@ import sys
from typing import Any, NamedTuple, Optional, Tuple, Union
if sys.version_info >= (3, 5):
SndHeaders = NamedTuple('SndHeaders', [
('filetype', str),
('framerate', int),
('nchannels', int),
('nframes', int),
('sampwidth', Union[int, str]),
])
class SndHeaders(NamedTuple):
filetype: str
framerate: int
nchannels: int
nframes: int
sampwidth: Union[int, str]
_SndHeaders = SndHeaders
else:
_SndHeaders = Tuple[str, int, int, int, Union[int, str]]

View File

@@ -87,12 +87,13 @@ def get_server_certificate(addr: Tuple[str, int], ssl_version: int = ...,
ca_certs: Optional[str] = ...) -> str: ...
def DER_cert_to_PEM_cert(der_cert_bytes: bytes) -> str: ...
def PEM_cert_to_DER_cert(pem_cert_string: str) -> bytes: ...
DefaultVerifyPaths = NamedTuple('DefaultVerifyPaths',
[('cafile', str), ('capath', str),
('openssl_cafile_env', str),
('openssl_cafile', str),
('openssl_capath_env', str),
('openssl_capath', str)])
class DefaultVerifyPaths(NamedTuple):
cafile: str
capath: str
openssl_cafile_env: str
openssl_cafile: str
openssl_capath_env: str
openssl_capath: str
def get_default_verify_paths() -> DefaultVerifyPaths: ...
if sys.platform == 'win32':
@@ -173,13 +174,16 @@ ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE: int
ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION: int
ALERT_DESCRIPTION_USER_CANCELLED: int
class _ASN1Object(NamedTuple):
nid: int
shortname: str
longname: str
oid: str
if sys.version_info < (3,):
class _ASN1Object(NamedTuple('_ASN1Object', [('nid', int), ('shortname', str), ('longname', str), ('oid', str)])): ...
class Purpose(_ASN1Object):
SERVER_AUTH: ClassVar[Purpose]
CLIENT_AUTH: ClassVar[Purpose]
else:
class _ASN1Object(NamedTuple('_ASN1Object', [('nid', int), ('shortname', str), ('longname', str), ('oid', str)])): ...
class Purpose(_ASN1Object, enum.Enum):
SERVER_AUTH: _ASN1Object
CLIENT_AUTH: _ASN1Object

View File

@@ -25,14 +25,13 @@ AUDIO_UNKNOWN_SIZE: int
if sys.version_info < (3, 0):
_sunau_params = Tuple[int, int, int, int, str, str]
else:
_sunau_params = NamedTuple('_sunau_params', [
('nchannels', int),
('sampwidth', int),
('framerate', int),
('nframes', int),
('comptype', str),
('compname', str),
])
class _sunau_params(NamedTuple):
nchannels: int
sampwidth: int
framerate: int
nframes: int
comptype: str
compname: str
class Au_read:
def __init__(self, f: _File) -> None: ...

View File

@@ -32,15 +32,19 @@ if sys.version_info >= (3, 8) and sys.platform == "darwin":
CLOCK_UPTIME_RAW: int
if sys.version_info >= (3, 3):
class struct_time(
NamedTuple(
'_struct_time',
[('tm_year', int), ('tm_mon', int), ('tm_mday', int),
('tm_hour', int), ('tm_min', int), ('tm_sec', int),
('tm_wday', int), ('tm_yday', int), ('tm_isdst', int),
('tm_zone', str), ('tm_gmtoff', int)]
)
):
class _struct_time(NamedTuple):
tm_year: int
tm_mon: int
tm_mday: int
tm_hour: int
tm_min: int
tm_sec: int
tm_wday: int
tm_yday: int
tm_isdst: int
tm_zone: str
tm_gmtoff: int
class struct_time(_struct_time):
def __init__(
self,
o: Union[
@@ -60,14 +64,17 @@ if sys.version_info >= (3, 3):
_arg: Any = ...,
) -> struct_time: ...
else:
class struct_time(
NamedTuple(
'_struct_time',
[('tm_year', int), ('tm_mon', int), ('tm_mday', int),
('tm_hour', int), ('tm_min', int), ('tm_sec', int),
('tm_wday', int), ('tm_yday', int), ('tm_isdst', int)]
)
):
class _struct_time(NamedTuple):
tm_year: int
tm_mon: int
tm_mday: int
tm_hour: int
tm_min: int
tm_sec: int
tm_wday: int
tm_yday: int
tm_isdst: int
class struct_time(_struct_time):
def __init__(self, o: _TimeTuple, _arg: Any = ...) -> None: ...
def __new__(cls, o: _TimeTuple, _arg: Any = ...) -> struct_time: ...

View File

@@ -29,13 +29,13 @@ def simplefilter(action: str, category: Type[Warning] = ..., lineno: int = ...,
append: bool = ...) -> None: ...
def resetwarnings() -> None: ...
_Record = NamedTuple('_Record',
[('message', str),
('category', Type[Warning]),
('filename', str),
('lineno', int),
('file', Optional[TextIO]),
('line', Optional[str])])
class _Record(NamedTuple):
message: str
category: Type[Warning]
filename: str
lineno: int
file: Optional[TextIO]
line: Optional[str]
class catch_warnings:
def __init__(self, *, record: bool = ...,

View File

@@ -14,14 +14,13 @@ WAVE_FORMAT_PCM: int
if sys.version_info < (3, 0):
_wave_params = Tuple[int, int, int, int, str, str]
else:
_wave_params = NamedTuple('_wave_params', [
('nchannels', int),
('sampwidth', int),
('framerate', int),
('nframes', int),
('comptype', str),
('compname', str),
])
class _wave_params(NamedTuple):
nchannels: int
sampwidth: int
framerate: int
nframes: int
comptype: str
compname: str
class Wave_read:
def __init__(self, f: _File) -> None: ...

View File

@@ -35,14 +35,10 @@ TIMEOUT_MAX: int
if sys.version_info >= (3, 8):
def get_native_id() -> int: ... # only available on some platforms
ExceptHookArgs = NamedTuple(
"ExceptHookArgs",
[
("exc_type", Type[BaseException]),
("exc_value", Optional[BaseException]),
("exc_traceback", Optional[TracebackType]),
("thread", Optional[Thread]),
]
)
class ExceptHookArgs(NamedTuple):
exc_type: Type[BaseException]
exc_value: Optional[BaseException]
exc_traceback: Optional[TracebackType]
thread: Optional[Thread]
def _ExceptHookArgs(args) -> ExceptHookArgs: ...
_excepthook: Callable[[ExceptHookArgs], Any]

View File

@@ -13,13 +13,11 @@ def reduce(function: Callable[[_T, _S], _T],
def reduce(function: Callable[[_T, _T], _T],
sequence: Iterable[_T]) -> _T: ...
class _CacheInfo(NamedTuple('CacheInfo', [
('hits', int),
('misses', int),
('maxsize', int),
('currsize', int)
])): ...
class _CacheInfo(NamedTuple):
hits: int
misses: int
maxsize: int
currsize: int
class _lru_cache_wrapper(Generic[_T]):
__wrapped__: Callable[..., _T]

View File

@@ -37,11 +37,11 @@ if sys.version_info >= (3, 6):
TPFLAGS_IS_ABSTRACT: int
if sys.version_info < (3, 6):
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 getmoduleinfo(path: str) -> Optional[ModuleInfo]: ...
def getmembers(object: object,
@@ -170,37 +170,36 @@ class BoundArguments:
# _ClassTreeItem = Union[List[_ClassTreeItem], Tuple[type, Tuple[type, ...]]]
def getclasstree(classes: List[type], unique: bool = ...) -> Any: ...
ArgSpec = NamedTuple('ArgSpec', [('args', List[str]),
('varargs', str),
('keywords', str),
('defaults', Tuple[Any, ...]),
])
class ArgSpec(NamedTuple):
args: List[str]
varargs: str
keywords: str
defaults: Tuple[Any, ...]
Arguments = NamedTuple('Arguments', [('args', List[str]),
('varargs', Optional[str]),
('varkw', Optional[str]),
])
class Arguments(NamedTuple):
args: List[str]
varargs: Optional[str]
varkw: Optional[str]
def getargs(co: CodeType) -> Arguments: ...
def getargspec(func: object) -> ArgSpec: ...
FullArgSpec = NamedTuple('FullArgSpec', [('args', List[str]),
('varargs', Optional[str]),
('varkw', Optional[str]),
('defaults', Optional[Tuple[Any, ...]]),
('kwonlyargs', List[str]),
('kwonlydefaults', Optional[Dict[str, Any]]),
('annotations', Dict[str, Any]),
])
class FullArgSpec(NamedTuple):
args: List[str]
varargs: Optional[str]
varkw: Optional[str]
defaults: Optional[Tuple[Any, ...]]
kwonlyargs: List[str]
kwonlydefaults: Optional[Dict[str, Any]]
annotations: Dict[str, Any]
def getfullargspec(func: object) -> FullArgSpec: ...
# TODO make the field types more specific here
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]
def getargvalues(frame: FrameType) -> ArgInfo: ...
def formatannotation(annotation: object, base_module: Optional[str] = ...) -> str: ...
@@ -234,12 +233,11 @@ def getcallargs(func: Callable[..., Any],
*args: Any,
**kwds: Any) -> Dict[str, Any]: ...
ClosureVars = NamedTuple('ClosureVars', [('nonlocals', Mapping[str, Any]),
('globals', Mapping[str, Any]),
('builtins', Mapping[str, Any]),
('unbound', AbstractSet[str]),
])
class ClosureVars(NamedTuple):
nonlocals: Mapping[str, Any]
globals: Mapping[str, Any]
builtins: Mapping[str, Any]
unbound: AbstractSet[str]
def getclosurevars(func: Callable[..., Any]) -> ClosureVars: ...
def unwrap(func: Callable[..., Any],
@@ -251,25 +249,20 @@ def unwrap(func: Callable[..., 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
# Python 3.5+ (functions returning it used to return regular tuples)
FrameInfo = NamedTuple('FrameInfo', [('frame', FrameType),
('filename', str),
('lineno', int),
('function', str),
('code_context', Optional[List[str]]),
('index', Optional[int]),
])
class FrameInfo(NamedTuple):
frame: FrameType
filename: str
lineno: int
function: str
code_context: Optional[List[str]]
index: Optional[int] # type: ignore
def getframeinfo(frame: Union[FrameType, TracebackType], context: int = ...) -> Traceback: ...
def getouterframes(frame: Any, context: int = ...) -> List[FrameInfo]: ...
@@ -311,10 +304,10 @@ def getgeneratorlocals(generator: Generator[Any, Any, Any]) -> Dict[str, Any]: .
# TODO can we be more specific than "object"?
def getcoroutinelocals(coroutine: object) -> Dict[str, Any]: ...
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]: ...

View File

@@ -20,17 +20,15 @@ class NNTPDataError(NNTPError): ...
NNTP_PORT: int
NNTP_SSL_PORT: int
GroupInfo = NamedTuple('GroupInfo', [
('group', str),
('last', str),
('first', str),
('flag', str),
])
ArticleInfo = NamedTuple('ArticleInfo', [
('number', int),
('message_id', str),
('lines', List[bytes]),
])
class GroupInfo(NamedTuple):
group: str
last: str
first: str
flag: str
class ArticleInfo(NamedTuple):
number: int
message_id: str
lines: List[bytes]
def decode_header(header_str: str) -> str: ...

View File

@@ -393,7 +393,9 @@ if sys.platform != 'win32':
def readv(fd: int, buffers: Sequence[bytearray]) -> int: ...
def writev(fd: int, buffers: Sequence[bytes]) -> int: ...
terminal_size = NamedTuple('terminal_size', [('columns', int), ('lines', int)])
class terminal_size(NamedTuple):
columns: int
lines: int
def get_terminal_size(fd: int = ...) -> terminal_size: ...
def get_inheritable(fd: int) -> bool: ...

View File

@@ -12,7 +12,13 @@ def java_ver(release: str = ..., vendor: str = ..., vminfo: Tuple[str, str, str]
def system_alias(system: str, release: str, version: str) -> Tuple[str, str, str]: ...
def architecture(executable: str = ..., bits: str = ..., linkage: str = ...) -> Tuple[str, str]: ...
uname_result = NamedTuple('uname_result', [('system', str), ('node', str), ('release', str), ('version', str), ('machine', str), ('processor', str)])
class uname_result(NamedTuple):
system: str
node: str
release: str
version: str
machine: str
processor: str
def uname() -> uname_result: ...
def system() -> str: ...

View File

@@ -10,34 +10,29 @@ from os import stat_result as stat_result
if sys.version_info >= (3, 6):
from builtins import _PathLike # See comment in builtins
uname_result = NamedTuple('uname_result', [
('sysname', str),
('nodename', str),
('release', str),
('version', str),
('machine', str),
])
class uname_result(NamedTuple):
sysname: str
nodename: str
release: str
version: str
machine: str
times_result = NamedTuple('times_result', [
('user', float),
('system', float),
('children_user', float),
('children_system', float),
('elapsed', float),
])
class times_result(NamedTuple):
user: float
system: float
children_user: float
children_system: float
elapsed: float
waitid_result = NamedTuple('waitid_result', [
('si_pid', int),
('si_uid', int),
('si_signo', int),
('si_status', int),
('si_code', int),
])
sched_param = NamedTuple('sched_param', [
('sched_priority', int),
])
class waitid_result(NamedTuple):
si_pid: int
si_uid: int
si_signo: int
si_status: int
si_code: int
class sched_param(NamedTuple):
sched_priority: int
EX_CANTCREAT: int
EX_CONFIG: int

View File

@@ -25,12 +25,23 @@ RUSAGE_CHILDREN: int
RUSAGE_SELF: int
RUSAGE_THREAD: 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 getpagesize() -> int: ...
def getrlimit(resource: int) -> Tuple[int, int]: ...

View File

@@ -12,18 +12,14 @@ _FileObject = Union[int, _HasFileno]
_FileDescriptor = int
_EventMask = int
EVENT_READ: _EventMask
EVENT_WRITE: _EventMask
SelectorKey = NamedTuple('SelectorKey', [
('fileobj', _FileObject),
('fd', _FileDescriptor),
('events', _EventMask),
('data', Any)
])
class SelectorKey(NamedTuple):
fileobj: _FileObject
fd: _FileDescriptor
events: _EventMask
data: Any
class BaseSelector(metaclass=ABCMeta):
@abstractmethod

View File

@@ -1,14 +1,15 @@
from typing import List, NamedTuple
struct_spwd = NamedTuple("struct_spwd", [("sp_namp", str),
("sp_pwdp", 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_namp: str
sp_pwdp: 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: ...

View File

@@ -10,13 +10,12 @@ if sys.version_info < (3, 7):
_Position = Tuple[int, int]
_TokenInfo = NamedTuple('TokenInfo', [
('type', int),
('string', str),
('start', _Position),
('end', _Position),
('line', str)
])
class _TokenInfo(NamedTuple):
type: int
string: str
start: _Position
end: _Position
line: str
class TokenInfo(_TokenInfo):
@property

View File

@@ -39,31 +39,33 @@ class _DefragResultBase(Tuple[Any, ...], Generic[AnyStr]):
fragment: AnyStr
_SplitResultBase = NamedTuple(
'_SplitResultBase',
[
('scheme', str), ('netloc', str), ('path', str), ('query', str), ('fragment', str)
]
)
_SplitResultBytesBase = NamedTuple(
'_SplitResultBytesBase',
[
('scheme', bytes), ('netloc', bytes), ('path', bytes), ('query', bytes), ('fragment', bytes)
]
)
class _SplitResultBase(NamedTuple):
scheme: str
netloc: str
path: str
query: str
fragment: str
class _SplitResultBytesBase(NamedTuple):
scheme: bytes
netloc: bytes
path: bytes
query: bytes
fragment: bytes
_ParseResultBase = NamedTuple(
'_ParseResultBase',
[
('scheme', str), ('netloc', str), ('path', str), ('params', str), ('query', str), ('fragment', str)
]
)
_ParseResultBytesBase = NamedTuple(
'_ParseResultBytesBase',
[
('scheme', bytes), ('netloc', bytes), ('path', bytes), ('params', bytes), ('query', bytes), ('fragment', bytes)
]
)
class _ParseResultBase(NamedTuple):
scheme: str
netloc: str
path: str
params: str
query: str
fragment: str
class _ParseResultBytesBase(NamedTuple):
scheme: bytes
netloc: bytes
path: bytes
params: bytes
query: bytes
fragment: bytes
# Structured result objects for string data
class DefragResult(_DefragResultBase[str], _ResultMixinStr): ...

View File

@@ -3,7 +3,9 @@
from typing import Iterable, NamedTuple, Optional
import sys
_RequestRate = NamedTuple('_RequestRate', [('requests', int), ('seconds', int)])
class _RequestRate(NamedTuple):
requests: int
seconds: int
class RobotFileParser:
def __init__(self, url: str = ...) -> None: ...