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

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