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

@@ -1,5 +1,4 @@
from typing import Any
from collections import namedtuple
from typing import Any, Dict, NamedTuple, Tuple
singledispatch: Any
@@ -104,6 +103,8 @@ class Runner:
def result_callback(self, key): ...
def handle_exception(self, typ, value, tb): ...
Arguments = namedtuple('Arguments', ['args', 'kwargs'])
class Arguments(NamedTuple):
args: Tuple[str, ...]
kwargs: Dict[str, Any]
def convert_yielded(yielded): ...

View File

@@ -1,6 +1,6 @@
from typing import Any, Dict
from typing import Any, Dict, NamedTuple
from tornado.util import ObjectDict
from collections import namedtuple
class SSLError(Exception): ...
@@ -79,11 +79,17 @@ def parse_body_arguments(content_type, body, arguments, files, headers=...): ...
def parse_multipart_form_data(boundary, data, arguments, files): ...
def format_timestamp(ts): ...
RequestStartLine = namedtuple('RequestStartLine', ['method', 'path', 'version'])
class RequestStartLine(NamedTuple):
method: str
path: str
version: str
def parse_request_start_line(line): ...
ResponseStartLine = namedtuple('ResponseStartLine', ['version', 'code', 'reason'])
class ResponseStartLine(NamedTuple):
version: str
code: str
reason: str
def parse_response_start_line(line): ...
def doctests(): ...

View File

@@ -11,14 +11,14 @@ if sys.version_info >= (3,):
from inspect import iscoroutinefunction as iscoroutinefunction
from inspect import getfullargspec as getfullargspec
else:
FullArgSpec = NamedTuple('FullArgSpec', [('args', List[str]),
('varargs', Optional[str]),
('varkw', Optional[str]),
('defaults', Tuple[Any, ...]),
('kwonlyargs', List[str]),
('kwonlydefaults', Dict[str, Any]),
('annotations', Dict[str, Any]),
])
class FullArgSpec(NamedTuple):
args: List[str]
varargs: Optional[str]
varkw: Optional[str]
defaults: Tuple[Any, ...]
kwonlyargs: List[str]
kwonlydefaults: Dict[str, Any]
annotations: Dict[str, Any]
def iscoroutinefunction(f: Callable[..., Any]) -> bool: ...
def getfullargspec(func: Any) -> FullArgSpec: ...

View File

@@ -37,7 +37,9 @@ def do_batch(value, linecount, fill_with: Optional[Any] = ...): ...
def do_round(value, precision: int = ..., method: str = ...): ...
def do_groupby(environment, value, attribute): ...
_GroupTuple = NamedTuple("_GroupTuple", [("grouper", Any), ("list", Any)])
class _GroupTuple(NamedTuple):
grouper: Any
list: Any
def do_sum(environment, iterable, attribute: Optional[Any] = ..., start: int = ...): ...
def do_list(value): ...

View File

@@ -1,12 +1,11 @@
from collections import namedtuple
from typing import Any, Optional, Text
_URLTuple = namedtuple(
'_URLTuple',
['scheme', 'netloc', 'path', 'query', 'fragment']
)
from typing import Any, NamedTuple, Optional, Text
class _URLTuple(NamedTuple):
scheme: Any
netloc: Any
path: Any
query: Any
fragment: Any
class BaseURL(_URLTuple):
def replace(self, **kwargs): ...