Use explicit "# type: str" instead of '' shortcut.

This commit is contained in:
Matthias Kramm
2015-11-09 07:59:14 -08:00
parent 63e441e804
commit d2a3d4a4ed
28 changed files with 139 additions and 137 deletions

View File

@@ -24,7 +24,7 @@ classmethod = object() # Special, only valid as a decorator.
property = object()
class object:
__doc__ = ''
__doc__ = ... # type: str
__class__ = ... # type: type
def __init__(self) -> None: ...
@@ -35,8 +35,8 @@ class object:
def __hash__(self) -> int: ...
class type:
__name__ = ''
__module__ = ''
__name__ = ... # type: str
__module__ = ... # type: str
__dict__ = ... # type: Dict[unicode, Any]
@overload
@@ -461,8 +461,8 @@ class tuple(Sequence[_T_co], Generic[_T_co]):
class function:
# TODO name of the class (corresponds to Python 'function' class)
__name__ = ''
__module__ = ''
__name__ = ... # type: str
__module__ = ... # type: str
class list(MutableSequence[_T], Reversible[_T], Generic[_T]):
@overload
@@ -594,8 +594,8 @@ class xrange(Sized, Iterable[int], Reversible[int]):
def __reversed__(self) -> Iterator[int]: ...
class module:
__name__ = ''
__file__ = ''
__name__ = ... # type: str
__file__ = ... # type: str
__dict__ = ... # type: Dict[unicode, Any]
True = ... # type: bool
@@ -757,8 +757,9 @@ class ArithmeticError(StandardError): ...
class BufferError(StandardError): ...
class EnvironmentError(StandardError):
errno = 0
strerror = ''
filename = '' # TODO can this be unicode?
strerror = ... # type: str
# TODO can this be unicode?
filename = ... # type: str
class LookupError(StandardError): ...
class RuntimeError(StandardError): ...
class ValueError(StandardError): ...

View File

@@ -40,7 +40,7 @@ class _version_info(Tuple[int, int, int, str, int]):
major = 0
minor = 0
micro = 0
releaselevel = ''
releaselevel = ... # type: str
serial = 0
_mercurial = ... # type: Tuple[str, str, str]
@@ -75,8 +75,8 @@ version = ... # type: str
warnoptions = ... # type: object
float_info = ... # type: _float_info
version_info = ... # type: _version_info
ps1 = ''
ps2 = ''
ps1 = ... # type: str
ps2 = ... # type: str
last_type = ... # type: type
last_value = ... # type: BaseException
last_traceback = ... # type: TracebackType

View File

@@ -4,12 +4,12 @@
from typing import Any, Iterable, Tuple, List, Iterator, BinaryIO, overload
typecodes = ''
typecodes = ... # type: str
class array:
def __init__(self, typecode: str,
initializer: Iterable[Any] = None) -> None:
typecode = ''
typecode = ... # type: str
itemsize = 0
def append(self, x: Any) -> None: ...

View File

@@ -26,7 +26,7 @@ classmethod = object() # Only valid as a decorator.
property = object()
class object:
__doc__ = ''
__doc__ = ... # type: str
__class__ = ... # type: type
def __init__(self) -> None: ...
@@ -37,9 +37,9 @@ class object:
def __hash__(self) -> int: ...
class type:
__name__ = ''
__qualname__ = ''
__module__ = ''
__name__ = ... # type: str
__qualname__ = ... # type: str
__module__ = ... # type: str
__dict__ = ... # type: Dict[str, Any]
def __init__(self, o: object) -> None: ...
@@ -431,9 +431,9 @@ class tuple(Sequence[_T_co], Generic[_T_co]):
class function:
# TODO not defined in builtins!
__name__ = ''
__qualname__ = ''
__module__ = ''
__name__ = ... # type: str
__qualname__ = ... # type: str
__module__ = ... # type: str
__code__ = ... # type: Any
class list(MutableSequence[_T], Reversible[_T], Generic[_T]):
@@ -595,8 +595,8 @@ class range(Sequence[int], Reversible[int]):
class module:
# TODO not defined in builtins!
__name__ = ''
__file__ = ''
__name__ = ... # type: str
__file__ = ... # type: str
__dict__ = ... # type: Dict[str, Any]
True = ... # type: bool
@@ -732,8 +732,9 @@ class Exception(BaseException): ...
class ArithmeticError(Exception): ...
class EnvironmentError(Exception):
errno = 0
strerror = ''
filename = '' # TODO can this be bytes?
strerror = ... # type: str
# TODO can this be bytes?
filename = ... # type: str
class LookupError(Exception): ...
class RuntimeError(Exception): ...
class ValueError(Exception): ...

View File

@@ -3,8 +3,8 @@ from typing import List
# TODO group database entry object type
class struct_group:
gr_name = ''
gr_passwd = ''
gr_name = ... # type: str
gr_passwd = ... # type: str
gr_gid = 0
gr_mem = ... # type: List[str]

View File

@@ -6,13 +6,13 @@ import typing
class struct_passwd:
# TODO use namedtuple
pw_name = ''
pw_passwd = ''
pw_name = ... # type: str
pw_passwd = ... # type: str
pw_uid = 0
pw_gid = 0
pw_gecos = ''
pw_dir = ''
pw_shell = ''
pw_gecos = ... # type: str
pw_dir = ... # type: str
pw_shell = ... # type: str
def getpwuid(uid: int) -> struct_passwd: ...
def getpwnam(name: str) -> struct_passwd: ...

View File

@@ -9,18 +9,18 @@ from typing import (
from types import TracebackType
# ----- sys variables -----
abiflags = ''
abiflags = ... # type: str
argv = ... # type: List[str]
byteorder = ''
byteorder = ... # type: str
builtin_module_names = ... # type: Sequence[str] # actually a tuple of strings
copyright = ''
copyright = ... # type: str
#dllhandle = 0 # Windows only
dont_write_bytecode = False
__displayhook__ = ... # type: Any # contains the original value of displayhook
__excepthook__ = ... # type: Any # contains the original value of excepthook
exec_prefix = ''
executable = ''
float_repr_style = ''
exec_prefix = ... # type: str
executable = ... # type: str
float_repr_style = ... # type: str
hexversion = 0 # this is a 32-bit int
last_type = ... # type: Any
last_value = ... # type: Any
@@ -32,10 +32,10 @@ modules = ... # type: Dict[str, Any]
path = ... # type: List[str]
path_hooks = ... # type: List[Any] # TODO precise type; function, path to finder
path_importer_cache = ... # type: Dict[str, Any] # TODO precise type
platform = ''
prefix = ''
ps1 = ''
ps2 = ''
platform = ... # type: str
prefix = ... # type: str
ps1 = ... # type: str
ps2 = ... # type: str
stdin = ... # type: TextIO
stdout = ... # type: TextIO
stderr = ... # type: TextIO
@@ -45,7 +45,7 @@ __stderr__ = ... # type: TextIO
# deprecated and removed in Python 3.3:
subversion = ... # type: Tuple[str, str, str]
tracebacklimit = 0
version = ''
version = ... # type: str
api_version = 0
warnoptions = ... # type: Any
# Each entry is a tuple of the form (action, message, category, module,
@@ -102,7 +102,7 @@ class _version_info(Tuple[int, int, int, str, int]):
major = 0
minor = 0
micro = 0
releaselevel = ''
releaselevel = ... # type: str
serial = 0
version_info = ... # type: _version_info

View File

@@ -9,14 +9,14 @@ from typing import overload, List, Any, Tuple, BinaryIO, TextIO, TypeVar, Callab
# ----- os.path variables -----
supports_unicode_filenames = False
# aliases (also in os)
curdir = ''
pardir = ''
sep = ''
altsep = ''
extsep = ''
pathsep = ''
defpath = ''
devnull = ''
curdir = ... # type: str
pardir = ... # type: str
sep = ... # type: str
altsep = ... # type: str
extsep = ... # type: str
pathsep = ... # type: str
defpath = ... # type: str
devnull = ... # type: str
# ----- os.path function stubs -----
def abspath(path: AnyStr) -> AnyStr: ...

View File

@@ -4,18 +4,18 @@
from typing import Mapping, Sequence, Any, Optional, Union, List, Tuple, Iterable, AnyStr
ascii_letters = ''
ascii_lowercase = ''
ascii_uppercase = ''
digits = ''
hexdigits = ''
letters = ''
lowercase = ''
octdigits = ''
punctuation = ''
printable = ''
uppercase = ''
whitespace = ''
ascii_letters = ... # type: str
ascii_lowercase = ... # type: str
ascii_uppercase = ... # type: str
digits = ... # type: str
hexdigits = ... # type: str
letters = ... # type: str
lowercase = ... # type: str
octdigits = ... # type: str
punctuation = ... # type: str
printable = ... # type: str
uppercase = ... # type: str
whitespace = ... # type: str
def capwords(s: AnyStr, sep: AnyStr = None) -> AnyStr: ...
# TODO: originally named 'from'
@@ -49,7 +49,7 @@ def replace(s: AnyStr, old: AnyStr, new: AnyStr, maxreplace: int = None) -> AnyS
class Template(object):
# TODO: Unicode support?
template = ''
template = ... # type: str
def __init__(self, template: str) -> None: ...
def substitute(self, mapping: Mapping[str, str], **kwds: str) -> str: ...

View File

@@ -26,8 +26,8 @@ STDOUT = ... # type: int
class CalledProcessError(Exception):
returncode = 0
cmd = ''
output = '' # May be None
cmd = ... # type: str
output = ... # type: str # May be None
def __init__(self, returncode: int, cmd: str, output: str) -> None: ...

View File

@@ -7,8 +7,8 @@
from typing import Tuple, IO
# global variables
tempdir = ''
template = ''
tempdir = ... # type: str
template = ... # type: str
# TODO text files
@@ -26,7 +26,7 @@ def SpooledTemporaryFile(
...
class TemporaryDirectory:
name = ''
name = ... # type: str
def __init__(self, suffix: str = '', prefix: str = 'tmp',
dir: str = None) -> None: ...
def cleanup(self) -> None: ...

View File

@@ -10,7 +10,7 @@ def currentThread() -> Thread: ...
def enumerate() -> List[Thread]: ...
class Thread(object):
name = ''
name = ... # type: str
ident = 0
daemon = False

View File

@@ -8,7 +8,7 @@ uses_params = [] # type: List[str]
non_hierarchical = [] # type: List[str]
uses_query = [] # type: List[str]
uses_fragment = [] # type: List[str]
scheme_chars = ''
scheme_chars = ... # type: str
MAX_CACHE_SIZE = 0
def clear_cache() -> None: ...

View File

@@ -18,7 +18,7 @@ class _TracebackLogger:
def __del__(self) -> None: ...
class Future(Iterator[_T], Generic[_T]):
_state = ''
_state = ... # type: str
_exception = Any #Exception
_blocking = False
_log_traceback = False

View File

@@ -9,7 +9,7 @@ class Enum:
def __hash__(self) -> Any: ...
def __reduce_ex__(self, proto: Any) -> Any: ...
name = ''
name = ... # type: str
value = None # type: Any
class IntEnum(int, Enum): ...

View File

@@ -13,7 +13,7 @@ def gnu_getopt(args: List[str], shortopts: str,
List[str]]: ...
class GetoptError(Exception):
msg = ''
opt = ''
msg = ... # type: str
opt = ... # type: str
error = GetoptError

View File

@@ -46,15 +46,15 @@ O_DIRECTORY = 0 # Gnu extension if in C library
O_NOFOLLOW = 0 # Gnu extension if in C library
O_NOATIME = 0 # Gnu extension if in C library
curdir = ''
pardir = ''
sep = ''
altsep = ''
extsep = ''
pathsep = ''
defpath = ''
linesep = ''
devnull = ''
curdir = ... # type: str
pardir = ... # type: str
sep = ... # type: str
altsep = ... # type: str
extsep = ... # type: str
pathsep = ... # type: str
defpath = ... # type: str
linesep = ... # type: str
devnull = ... # type: str
F_OK = 0
R_OK = 0

View File

@@ -8,14 +8,14 @@ from typing import overload, List, Any, AnyStr, Tuple, BinaryIO, TextIO
# ----- os.path variables -----
supports_unicode_filenames = False
# aliases (also in os)
curdir = ''
pardir = ''
sep = ''
altsep = ''
extsep = ''
pathsep = ''
defpath = ''
devnull = ''
curdir = ... # type: str
pardir = ... # type: str
sep = ... # type: str
altsep = ... # type: str
extsep = ... # type: str
pathsep = ... # type: str
defpath = ... # type: str
devnull = ... # type: str
# ----- os.path function stubs -----
def abspath(path: AnyStr) -> AnyStr: ...

View File

@@ -11,20 +11,20 @@ def split(s: str, comments: bool = False,
def quote(s: str) -> str: ...
class shlex:
commenters = ''
wordchars = ''
whitespace = ''
escape = ''
quotes = ''
escapedquotes = ''
whitespace_split = ''
infile = ''
commenters = ... # type: str
wordchars = ... # type: str
whitespace = ... # type: str
escape = ... # type: str
quotes = ... # type: str
escapedquotes = ... # type: str
whitespace_split = ... # type: str
infile = ... # type: str
instream = ... # type: TextIO
source = ''
source = ... # type: str
debug = 0
lineno = 0
token = ''
eof = ''
token = ... # type: str
eof = ... # type: str
def __init__(self, instream=None, infile=None,
posix: bool = False) -> None: ...

View File

@@ -4,20 +4,20 @@
from typing import Mapping
ascii_letters = ''
ascii_lowercase = ''
ascii_uppercase = ''
digits = ''
hexdigits = ''
octdigits = ''
punctuation = ''
printable = ''
whitespace = ''
ascii_letters = ... # type: str
ascii_lowercase = ... # type: str
ascii_uppercase = ... # type: str
digits = ... # type: str
hexdigits = ... # type: str
octdigits = ... # type: str
punctuation = ... # type: str
printable = ... # type: str
whitespace = ... # type: str
def capwords(s: str, sep: str = None) -> str: ...
class Template:
template = ''
template = ... # type: str
def __init__(self, template: str) -> None: ...
def substitute(self, mapping: Mapping[str, str], **kwds: str) -> str: ...

View File

@@ -26,7 +26,7 @@ STDOUT = ... # type: Any
class CalledProcessError(Exception):
returncode = 0
cmd = ''
cmd = ... # type: str
output = b'' # May be None
def __init__(self, returncode: int, cmd: str, output: str) -> None: ...

View File

@@ -5,7 +5,7 @@ from typing import Any, List, overload, Callable
class TarError(Exception): ...
class TarInfo:
name = ''
name = ... # type: str
size = 0
uid = 0
gid = 0

View File

@@ -6,8 +6,8 @@
from typing import Tuple, BinaryIO
# global variables
tempdir = ''
template = ''
tempdir = ... # type: str
template = ... # type: str
# TODO text files
@@ -29,7 +29,7 @@ def SpooledTemporaryFile(
...
class TemporaryDirectory:
name = ''
name = ... # type: str
def __init__(self, suffix: str = '', prefix: str = 'tmp',
dir: str = None) -> None: ...
def cleanup(self) -> None: ...

View File

@@ -5,7 +5,7 @@
from typing import Any, Dict, Optional, Callable, TypeVar, Union
class Thread:
name = ''
name = ... # type: str
ident = 0
daemon = False

View File

@@ -45,7 +45,7 @@ class TestResult:
class _AssertRaisesBaseContext:
expected = ... # type: Any
failureException = ... # type: type
obj_name = ''
obj_name = ... # type: str
expected_regex = ... # type: Pattern[str]
class _AssertRaisesContext(_AssertRaisesBaseContext):
@@ -55,7 +55,7 @@ class _AssertRaisesContext(_AssertRaisesBaseContext):
class _AssertWarnsContext(_AssertRaisesBaseContext):
warning = ... # type: Any # TODO precise type
filename = ''
filename = ... # type: str
lineno = 0
def __enter__(self) -> _AssertWarnsContext: ...
def __exit__(self, exc_type, exc_value, tb) -> bool: ...

View File

@@ -8,7 +8,7 @@ ZIP_DEFLATED = 0
def is_zipfile(filename: Union[str, BinaryIO]) -> bool: ...
class ZipInfo:
filename = ''
filename = ... # type: str
date_time = ... # type: Tuple[int, int, int, int, int, int]
compressed_size = 0
file_size = 0

View File

@@ -28,8 +28,8 @@ class ProcessPoolExecutor(Executor):
def wait(fs: Iterable[Future], timeout: float = None, return_when: str = None) -> Tuple[Iterable[Future], Iterable[Future]]: ...
FIRST_COMPLETED = ''
FIRST_EXCEPTION = ''
ALL_COMPLETED = ''
FIRST_COMPLETED = ... # type: str
FIRST_EXCEPTION = ... # type: str
ALL_COMPLETED = ... # type: str
def as_completed(fs: Iterable[Future], timeout: float = None) -> Iterator[Future]: ...

View File

@@ -67,12 +67,12 @@ class FlagValues:
FLAGS = None # type: FlagValues
class Flag:
name = ''
name = ... # type: str
default = None # type: Any
default_as_str = ''
default_as_str = ... # type: str
value = None # type: Any
help = ''
short_name = ''
help = ... # type: str
short_name = ... # type: str
boolean = False
present = False
parser = None # type: ArgumentParser
@@ -90,7 +90,7 @@ class Flag:
def WriteInfoInXMLFormat(self, outfile: IO[str], module_name: str, is_key: bool = False, indent: str = '') -> None: ...
class ArgumentParser(object):
syntactic_help = ""
syntactic_help = ... # type: str
# TODO what is this
def Parse(self, argument: Any) -> Any: ...
def Type(self) -> str: ...
@@ -149,9 +149,9 @@ class NumericParser(ArgumentParser):
def Convert(self, argument: Any) -> Any: ...
class FloatParser(NumericParser):
number_article = ''
number_name = ''
syntactic_help = ''
number_article = ... # type: str
number_name = ... # type: str
syntactic_help = ... # type: str
def __init__(self, lower_bound: float = None, upper_bound: float = None) -> None: ...
def Convert(self, argument: Any) -> float: ...
def Type(self) -> str: ...
@@ -160,9 +160,9 @@ def DEFINE_float(name: str, default: float, help: str, lower_bound: float = None
upper_bound: float = None, flag_values: FlagValues = ..., **args: Any) -> None: ...
class IntegerParser(NumericParser):
number_article = ''
number_name = ''
syntactic_help = ''
number_article = ... # type: str
number_name = ... # type: str
syntactic_help = ... # type: str
def __init__(self, lower_bound: int = None, upper_bound: int = None) -> None: ...
def Convert(self, argument: Any) -> int: ...
def Type(self) -> str: ...