Update textwrap stubs (#1634)

This commit adds a few missing return types to the Python 3 textwrap
stubs and fleshes out the Python 2 textwrap stubs so they're on par with
the Python 3 version.

This change:

1.  Changes the order of the arguments in Python 2 and Python 3
    to match the order from the source code instead of the
    documentation.

2.  Adds other undocumented attributes besides whitespace_trans
    (for consistency).

3.  Moves the '*' argument in TextWrapper.__init__ for Python 3
    to match the source code.

4.  Made function stub formatting consistent with typeshed style
    conventions.
This commit is contained in:
Michael Lee
2017-10-08 21:12:20 -07:00
committed by Jelle Zijlstra
parent 6a55ad5b60
commit 51829c1bc8
2 changed files with 108 additions and 83 deletions

View File

@@ -1,29 +1,63 @@
from typing import Any, AnyStr
from typing import AnyStr, List, Dict, Pattern
class _unicode: ...
class TextWrapper(object):
width: int = ...
initial_indent: str = ...
subsequent_indent: str = ...
expand_tabs: bool = ...
replace_whitespace: bool = ...
fix_sentence_endings: bool = ...
drop_whitespace: bool = ...
break_long_words: bool = ...
break_on_hyphens: bool = ...
class TextWrapper:
whitespace_trans = ... # type: Any
unicode_whitespace_trans = ... # type: Any
uspace = ... # type: Any
wordsep_re = ... # type: Any
wordsep_simple_re = ... # type: Any
sentence_end_re = ... # type: Any
width = ... # type: Any
initial_indent = ... # type: Any
subsequent_indent = ... # type: Any
expand_tabs = ... # type: Any
replace_whitespace = ... # type: Any
fix_sentence_endings = ... # type: Any
break_long_words = ... # type: Any
drop_whitespace = ... # type: Any
break_on_hyphens = ... # type: Any
wordsep_re_uni = ... # type: Any
wordsep_simple_re_uni = ... # type: Any
def __init__(self, width=..., initial_indent=..., subsequent_indent=..., expand_tabs=..., replace_whitespace=..., fix_sentence_endings=..., break_long_words=..., drop_whitespace=..., break_on_hyphens=...) -> None: ...
def wrap(self, text): ...
def fill(self, text): ...
# Attributes not present in documentation
sentence_end_re: Pattern[str] = ...
wordsep_re: Pattern[str] = ...
wordsep_simple_re: Pattern[str] = ...
whitespace_trans: str = ...
unicode_whitespace_trans: Dict[int, int] = ...
uspace: int = ...
x: int = ...
def wrap(text, width=..., **kwargs): ...
def fill(text, width=..., **kwargs): ...
def dedent(text: AnyStr) -> AnyStr: ...
def __init__(
self,
width: int = ...,
initial_indent: str = ...,
subsequent_indent: str = ...,
expand_tabs: bool = ...,
replace_whitespace: bool = ...,
fix_sentence_endings: bool = ...,
break_long_words: bool = ...,
drop_whitespace: bool = ...,
break_on_hyphens: bool = ...) -> None:
...
def wrap(self, text: AnyStr) -> List[AnyStr]: ...
def fill(self, text: AnyStr) -> AnyStr: ...
def wrap(
text: AnyStr,
width: int = ...,
initial_indent: str = ...,
subsequent_indent: str = ...,
expand_tabs: bool = ...,
replace_whitespace: bool = ...,
fix_sentence_endings: bool = ...,
break_long_words: bool = ...,
drop_whitespace: bool = ...,
break_on_hyphens: bool = ...) -> AnyStr:
...
def fill(
text: AnyStr,
width: int =...,
initial_indent: str = ...,
subsequent_indent: str = ...,
expand_tabs: bool = ...,
replace_whitespace: bool = ...,
fix_sentence_endings: bool = ...,
break_long_words: bool = ...,
drop_whitespace: bool = ...,
break_on_hyphens: bool = ...) -> AnyStr:
...