Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
201 commits
Select commit Hold shift + click to select a range
e7184d6
Add undocumented but used method LWPCookieJar.as_lwp_str. (#3041)
rchen152 Jun 8, 2019
d64a26c
Add missing constructor to types.CodeType. (#3040)
rchen152 Jun 8, 2019
55a5663
Add `copy()` method to requests.Session.headers (#3043)
connorskees Jun 8, 2019
ed2a851
dateutil: byweekday can take weekday (#3046)
asottile Jun 10, 2019
901cb33
Mark asyncio loop parameters as Optional (#3047)
li-wjohnson Jun 10, 2019
5327484
Use type annotation syntax (#3048)
ilevkivskyi Jun 11, 2019
b9101e9
Add a few Redis types (#3016)
srittau Jun 12, 2019
e4a9cd5
Add missing path-like annotation (#3053)
thejohnfreeman Jun 12, 2019
8e7c328
request.pyi: Change Union[] -> Any for attributing status. (#3045)
utkarsh2102 Jun 13, 2019
8ffe20f
Add redis stream methods to the client stubs (#3051)
joejuzl Jun 13, 2019
1f740a7
Adding stubs for pyre_extensions (#3056)
mrkmndz Jun 13, 2019
d36a519
Update select and selectors to use _HasFileno protocol (#3057)
Eric-Arellano Jun 15, 2019
1efebf7
Marshal dumps/loads uses bytes (#3061)
flacjacket Jun 16, 2019
6258e7d
ssl.pyi: fix types of cadata argument (#3063)
alexf91 Jun 16, 2019
5447ff6
str and unicode format functions take objects (#3068)
Jadiker Jun 17, 2019
fcb97fe
Overload ast.parse to recognize that mode=exec means Module return. (…
carljm Jun 17, 2019
01c2fa5
Sync recent typing and typing_extensions updates (#3070)
ilevkivskyi Jun 18, 2019
38f253e
redis: Add some type hints (#3055)
Jun 18, 2019
aa56af7
HTMLParser.get_starttag_text() can return None (#3072)
narusemotoki Jun 19, 2019
d149fe4
Represent the use of IntEnums in functions in socket.py. (#3009)
MatthewWilkes Jun 19, 2019
2e10326
change http.cookies.Morsel to Dict[str, Any] (#3060)
FlorianLudwig Jun 19, 2019
1763f51
Refactor tests/pytype_test.py (#3065)
Eric-Arellano Jun 19, 2019
58221cf
Add types and functions in types.py that are new in 3.7 (#3066)
CraftSpider Jun 19, 2019
2b6a99c
fix ssl.Purpose type in py3 (#3054)
Hanaasagi Jun 20, 2019
9941616
Add mp_context parameter to concurrent.futures.ProcessPoolExecutor (#…
crusaderky Jun 20, 2019
ada0570
Revert "Define functools.partial as overloaded function instead of it…
JelleZijlstra Jun 21, 2019
b0c9fa4
fix type of loop.sock_connect (#3073)
JelleZijlstra Jun 21, 2019
bdd49d0
Fix annotation of re.Match 'lastindex' and 'lastgroup' in Python 3 (#…
mthuurne Jun 22, 2019
e25c0cb
"key" argument of builtin function sorted should be optional in pytho…
chadrik Jun 22, 2019
64b12bf
itsdangerous: update JSONWebSignatureSerializer.dumps return type (#3…
redshiftzero Jun 22, 2019
8131bfc
Install Black and isort autoformatters (#3069)
Eric-Arellano Jun 24, 2019
7e9e91c
Restore default value to click.echo_via_pager (#3090)
chronitis Jun 26, 2019
5dc89fe
Add undocumented methods codecs.utf_16_be_{decode,encode}. (#3091)
rchen152 Jun 27, 2019
3272307
Make dataclasses.Field.metadata non-optional (#3094)
bgw Jun 29, 2019
4745062
Add TLSVersion & related attributes to SSLContext (#3097)
hynek Jul 1, 2019
8b66e08
Add Generic Typing to Queue.PriorityQueue and Queue.LifoQueue in pyth…
JasonGilholme Jul 1, 2019
c666998
xml.etree.ElementTree: fix missing None in get(), findtext() return t…
bluetech Jul 1, 2019
e1e5c83
QueueHandler / QueueListener accept SimpleQueue too (#3098)
mjpieters Jul 1, 2019
668d050
Fix contextlib GeneratorContextManager name for py>=3.2 (#3083)
RafiB Jul 2, 2019
75d9228
PurePath methods accept os.PathLike[str] from 3.6 (#3099)
fcolas Jul 2, 2019
3e70022
Add in multiprocessing.managers.ValueProxy types (#3100)
ikelos Jul 3, 2019
4af283e
Fix HTTPConnection.putrequest parameter names (#3101)
SamChou19815 Jul 3, 2019
84e6492
Improving Flask stubs (#3003)
s-kovacevic Jul 4, 2019
1436cfd
Add types to FileStorage (#3067)
srittau Jul 4, 2019
f5c107c
BytesGenerator requires BinaryIO (#3106)
cole Jul 8, 2019
b43e1d6
Use Literal overloads to give better types to subprocess (#3110)
msullivan Jul 10, 2019
4ae4714
sys: refine the return type of sys.exc_info() (#3111)
bluetech Jul 11, 2019
34b4710
Slice attributes can be of any type. (#3024)
brandtbucher Jul 11, 2019
40124b5
Update required pytype version to one that supports `async def`. (#3112)
rchen152 Jul 11, 2019
2a57ce2
Add curses.COLORS and curses.COLOR_PAIRS (#3115)
asottile Jul 13, 2019
f76b7b2
Re-export _curses._CursesWindow from curses (#3117)
asottile Jul 13, 2019
e2ec5d0
Make SyntaxError.text be optional (#3119)
Hanaasagi Jul 15, 2019
3ad3ed8
Overload the constructor of subprocess.Popen (#3113)
msullivan Jul 16, 2019
8e89faa
Added Optional (#3125)
WillAyd Jul 17, 2019
508f992
Add __eq__ to protobuf containers (#3126)
ilevkivskyi Jul 17, 2019
09d1055
Remove mypy new analyzer tests (#3128)
srittau Jul 18, 2019
40215d1
Fix the definition of nsmallest() in stdlib/2 and 2and3/heapq.pyi (#3…
yannack Jul 18, 2019
dad16f2
Update socket exceptions (#3127)
srittau Jul 18, 2019
90c2c22
Make python 2 subprocess consistent with python 3 (#3132)
msullivan Jul 19, 2019
4072ad8
Fix python 2 subprocess.Popen to produce Popen[bytes] (#3133)
msullivan Jul 19, 2019
9379ced
remove itertools.accumulate from Python 2 stubs (#3135)
metalogical Jul 20, 2019
9dcdc7d
faulthandler.dump_traceback_later: timeout can be float (#3134)
blueyed Jul 20, 2019
67d091d
Update google RepeatedCompositeFieldContainer (#3136)
nipunn1313 Jul 22, 2019
8e0d288
json: require a JSONDecoder/JSONEncoder in cls (#3138)
scop Jul 23, 2019
322be1b
Upgrade flake8* and isort versions (#3141)
scop Jul 23, 2019
8794e40
Fix ast.Constant availability (#3142)
zsol Jul 24, 2019
0177ded
Add werkzeug.middleware (#3103)
srittau Jul 24, 2019
9a7b286
warnings: ignore the type of category when message is a Warning (#3121)
bluetech Jul 24, 2019
bf50612
inspect: get{doc,comments,module,sourcefile} can return None (#3137)
scop Jul 24, 2019
b3f7be5
Fix __call__ type for GeneratorContextManager (#3143)
msullivan Jul 24, 2019
c9f9530
xml.etree.ElementTree: use literal type for a more precise return val…
bluetech Jul 25, 2019
32ee49c
Add zipfile.ZipFile.filename (#3104)
mthuurne Jul 25, 2019
b20e5b6
Travis: run mypy with Python 3.8 as well (#3146)
srittau Jul 25, 2019
e9d1f86
gettext stubs fixed (#3130)
jolaf Jul 25, 2019
df8ecf5
Fix incorrectly named parameters in logging module (#3148)
connorbrinton Jul 25, 2019
c356316
Use pytype.config.Options.create() for prettier code. (#3151)
rchen152 Jul 26, 2019
c8e7d98
Allow function.__code__ in Python 2 (#3152)
bluetech Jul 26, 2019
4697adc
[stdlib][3] Add missing typing.OrderedDict generic stub for Python 3.…
NeveHanter Jul 26, 2019
9ccf935
Remove Python 3.4 support (#3147)
srittau Jul 27, 2019
15aa18d
dateutil.rrule can take dates (#3154)
akaptur Jul 27, 2019
568f1ea
Add attributes to xml.etree.ElementTree.ParseError. (#3158)
mrshannon Jul 30, 2019
32a8980
curses: getch returns an integer (#3156)
asottile Jul 30, 2019
bd2d0fc
Add hints for 3 globals from logging/__init__.py (#3159)
bsolomon1124 Jul 30, 2019
c6cbe4d
inspect: use more specific arg type for some source retrieve function…
scop Jul 30, 2019
29dde6c
Fix type annotations for get_wch / unget_wch (#3157)
asottile Jul 30, 2019
c3b70d4
Require the newest pytype version, with a pyi parser fix. (#3160)
rchen152 Jul 30, 2019
4c8d577
flask: allow view func body to be dict (#3149)
ikonst Jul 31, 2019
edee7cf
Remove unused import from stdlib/2/htmlentitydefs.pyi (#3162)
jdufresne Jul 31, 2019
f2fdb54
Precise the type of Python 2 htmlentitydefs module (#3163)
jdufresne Jul 31, 2019
02401c8
Add type annotations for Python 3 html.entities (#3161)
jdufresne Jul 31, 2019
3c41419
Declare asyncio.as_completed() as taking an Iterable (#3164)
niligulmohar Jul 31, 2019
1dc24e1
Add nbytes to the memoryview definition (#3167)
pgjones Aug 3, 2019
d05a9d3
Improve enums (#3168)
JelleZijlstra Aug 5, 2019
29771aa
Add missing methods to asyncio stubs (#3088)
cole Aug 6, 2019
50f1988
concurrent: add private classes and exceptions (#3169)
gantsevdenis Aug 7, 2019
0dea39c
make basicConfig parameters Optional[...] (#3170)
V3RGANz Aug 7, 2019
6f01493
Move some constants from tokenize to token in Python 3.7+. (#3175)
rchen152 Aug 8, 2019
3f6cec9
Fix Match.group problems (#3172)
srittau Aug 8, 2019
c579f91
Improve werkzeug exceptions slightly (#3178)
srittau Aug 9, 2019
628eee2
Use Literal in a few more places (#3176)
srittau Aug 10, 2019
0dc3bf9
Improve type of tornado.testing.gen_test. (#3174)
benjaminp Aug 10, 2019
baea5a7
Widen the annotation of os.write to include buffer. (#3109)
benjaminp Aug 10, 2019
26f5751
Add some redis types (#3092)
Aug 10, 2019
15b7cda
Implement ZipExtFile in the zipfile type stubs (#3074)
CraftSpider Aug 10, 2019
679e1a9
Update URL: python/black → psf/black (#3180)
jdufresne Aug 10, 2019
1edd6cd
Add Match.regs (#2819)
scop Aug 11, 2019
b873894
Fix a typo (self -> cls) in stdlib/2/subprocess.pyi. (#3185)
rchen152 Aug 15, 2019
0ee7c3c
Update __import__ function annotations (#3188)
jdufresne Aug 16, 2019
5638d29
Fix #3187 : Wrong Signatures in socketserver (#3189)
nielsbuwen Aug 16, 2019
3cfc315
Partially restore old (imprecise) signature of Match.group() (#3190)
ilevkivskyi Aug 16, 2019
b294782
Make most contextmanager `__exit__` signatures return Optional[bool] …
Michael0x2a Aug 16, 2019
fab2ee0
Remove unnecessary quotes around forward references. (#3191)
rchen152 Aug 17, 2019
c0625d3
builtins: add __trunc__ to int and float (#3194)
bluetech Aug 17, 2019
c7417e8
builtins,numbers: harmonize float.__round__ and Real.__round__ (#3193)
bluetech Aug 17, 2019
b2cd972
builtins: int.__pow__ can take a modulo argument (#3192)
bluetech Aug 17, 2019
d5a918d
Add stubs for CGIHTTPServer (#3196)
Bouteillebleu Aug 19, 2019
e252094
multiprocessing.Value can also take a Type (#3200)
alanhdu Aug 19, 2019
1ab5145
adds threading related members to queue.pyi (#3198)
mchlnix Aug 19, 2019
72010bc
Update how mock classes alias to Any (#3182)
shannonzhu Aug 20, 2019
75ccbdc
cadata param can (and PEM-encoded cadata must) be unicode under PY2 (…
sfreilich Aug 23, 2019
04bcb89
create_server returns a Server, not AbstractServer (#3131)
scottbelden Aug 23, 2019
ce0f5b2
zipfile.ZipFile: Add start_dir attribute. (#3203)
benjaminp Aug 23, 2019
03b38d4
Add sys.flags.utf8_mode. (#3205)
rchen152 Aug 23, 2019
2824056
Make inplace sorting require mutable sequences in bisect module (#3199)
plokmijnuhby Aug 24, 2019
3e4a251
doctest: fix type of DocTestParser.get_doctest(lineno) (#3206)
bluetech Aug 24, 2019
cd1a0c5
Add typestubs for unittest.util (#3186)
jermenkoo Aug 27, 2019
a48abb4
Add unquote_to_bytes to Python 3 six.moves.urllib.parse. (#3208)
benjaminp Aug 29, 2019
f53f52d
requests: Allow bytes for url parameters. (#3209)
benjaminp Aug 29, 2019
d78747c
Make target optional in contextlib redirecting managers (#3212)
ateraz Aug 29, 2019
ae881fa
Remove custom _Text type (#3211)
srittau Aug 29, 2019
99e8ed4
Mark ParamType.fail() as NoReturn (#3213)
hexane360 Aug 29, 2019
f9300ed
Update pyre_extensions stub (#3214)
shannonzhu Aug 30, 2019
abc241b
Use Literal to improve tempfile.[Named]TemporaryFile. (#3215)
rchen152 Aug 31, 2019
b94fa84
Type response of Flask test client methods: get, post, etc. (#2904)
pcorpet Sep 3, 2019
1d21315
ssl.pyi: Add functions, support Path (#3044)
dholth Sep 3, 2019
efb4af0
Mark some types as non-hashable (#3219)
srittau Sep 4, 2019
3fc8aec
Allow passing str to Python 2's bytearray.extend. (#3223)
benjaminp Sep 4, 2019
668988f
Return concrete sets from ItemsView and KeysView (#3181)
kaste Sep 5, 2019
c9f19b1
Use protocol for FTP.stor* (#3227)
srittau Sep 10, 2019
686e21d
Fix type in argparse.HelpFormatter._fill_text() (#3229)
jjmortensen Sep 11, 2019
5ccf017
fix: Add MapResult type (#3228)
Hanaasagi Sep 11, 2019
8d053f1
Change SyncManager behaviour when used as a context decorator (#3230)
plokmijnuhby Sep 11, 2019
2b97bb9
Add AIFC module stubs (#3075)
CraftSpider Sep 11, 2019
2edb36e
Add ThreadingHTTPServer stub (#3232)
Hanaasagi Sep 15, 2019
d0f3eb2
Use Text for text arguments to click.[un]style (#3233)
ilevkivskyi Sep 16, 2019
895ae0f
requests.Session.request data arg accepts an iterable of tuples (#3237)
aegarbutt Sep 16, 2019
babc0c1
Accept bytes to several Redis client commands (#3238)
bsolomon1124 Sep 17, 2019
4c63939
setprofile accepts None (#3239)
Sep 17, 2019
ce0dc8a
Add proper support for __rtruediv__ on libpath.Path (#3236)
bluebird75 Sep 17, 2019
8b28753
Update and improve py_compile module stubs. (#3240)
carljm Sep 18, 2019
9488b58
Copy a better definition of abstractmethod from 3/abc to 2/abc. (#3242)
rchen152 Sep 18, 2019
0602840
Make the type of `timeout` Optional[float] everywhere in subprocess. …
rchen152 Sep 18, 2019
4d662f0
Stubs for maxminddb added (#3245)
jolaf Sep 19, 2019
c65b5cc
Changed combine method in datetime to use aliased _date and _time typ…
erictraut Sep 23, 2019
a011d19
add missing errnos (#3254)
Hanaasagi Sep 23, 2019
c879ff0
Changed type of fieldname parameter in DictWriter __init__ method fro…
erictraut Sep 23, 2019
01b7002
Introduce explicit `__str__` and `__repr__` for Exceptions (#3247)
sinancepel Sep 23, 2019
c1ec292
Added missing top-level export to click (#3256)
hackaugusto Sep 23, 2019
829c646
Added constructor types for click.FloatRange (#3257)
hackaugusto Sep 23, 2019
3f8c216
Define listdir in posix and import it in os. (#3258)
rchen152 Sep 23, 2019
c33239b
click: Support tuples of _ParamTypes, CliRunner fixes (#3259)
hexane360 Sep 24, 2019
e0cc8bd
inspect.Traceback/FrameInfo index/code_context attributes now Optiona…
arnimarj Sep 26, 2019
efdbefe
Add return types for pymysql.connection.close/cursor (#3268)
alexjurkiewicz Sep 27, 2019
d1ed2b2
Updated logging type stub (#3269)
brianjyoung Sep 27, 2019
4e1a45a
update `codecs.register` type definition (#3271)
parthsharma2 Sep 27, 2019
ac35a18
Make the `value` argument to ctypes.cbool.__init__ optional. (#3273)
rchen152 Sep 27, 2019
60bdf60
Add missing default for ssl_handshake_timeout agrument (#3277)
asvetlov Sep 29, 2019
c0371df
dir argument to tempfile functions may take PathLike (#3226)
asottile Sep 29, 2019
d4727c3
Add multiprocessing.Array (#3272)
alanhdu Sep 29, 2019
1e881ad
switched return_exceptions from bool to Literal for asyncio.gather (#…
hh-h Sep 29, 2019
b336182
Fix some errors with --disallow-any-generics (#3276)
Sep 29, 2019
95185fa
Improve the explanatory comment at the top of check_consistent.py
gvanrossum Sep 29, 2019
23232c0
Simplify Travis-CI configuration (#3220)
srittau Sep 30, 2019
468d13a
Modified __add__ method in tuple class (#3252)
erictraut Sep 30, 2019
412b9e7
Change last asyncio.gather() overload ret. to List (#3248)
bsolomon1124 Sep 30, 2019
ed4b1de
Fix third_party errors with --disallow-any-generics (#3278)
srittau Sep 30, 2019
c441a1f
Added ConfigParser.BOOLEAN_STATES # Undocumented (#3281)
jolaf Sep 30, 2019
aaff561
Added stub for urllib.request.proxy_bypass() (#3283)
jolaf Sep 30, 2019
a2834cf
Added stub for http.server.BaseHTTPRequestHandler useful undocumented…
jolaf Sep 30, 2019
785d783
Added stub for asyncore.socket_map, undocumented but useful (#3284)
jolaf Sep 30, 2019
23b3533
Allow passing bytes and byte string to yaml load APIs. (#3287)
benjaminp Sep 30, 2019
c32e1e2
Enable --disallow-any-generics for stubs (#3288)
srittau Oct 1, 2019
0abb50e
Add http.MISDIRECTED_REQUEST introduced in 3.7 (#3293)
stj Oct 1, 2019
ad881f9
Add the mypyc_attr function to mypy_extensions (#3290)
msullivan Oct 2, 2019
455f25a
Use Any instead of object in the view types for __and__ and __sub__ (…
msullivan Oct 2, 2019
eeb8daa
Remove some spurious version checks in logging (#3292)
msullivan Oct 2, 2019
c38cf67
Allow callables in _SourceObjectType (#3295)
JelleZijlstra Oct 2, 2019
9a1d205
cryptography: Return RSAPrivateKeyWithSerialization from generate_pri…
benjaminp Oct 2, 2019
fa571fb
builtins.pyi: Use two type vars (#3291)
utkarsh2102 Oct 3, 2019
e62857f
Updated maxminddb stubs to v1.5.0 (#3300)
jolaf Oct 4, 2019
41d23a6
ssl: add VerifyFlags flags and VerifyMode enum (#3302)
jlaine Oct 4, 2019
0a426d8
Move cryptography from 2 to 2and3 (#3304)
srittau Oct 4, 2019
90aa27b
Fix the signature of IOBase._checkClosed(). (#3305)
rchen152 Oct 4, 2019
8358984
rrule.weekday(...) returns rrule.weekdays, not _common.weekdays. (#3274)
glyph Oct 4, 2019
cd418e9
introduce __floor__ and __ceil__ for int in Python 3 (#3306)
sinancepel Oct 5, 2019
79a8f0b
imaplib.pyi: Take strings as args instead of a list of strings (#3308)
utkarsh2102 Oct 5, 2019
3743b64
IncrementalNewlineDecoder.decode accepts str (#3312)
rmorshea Oct 6, 2019
b9342ec
add IncrementalNewlineDecoder constructor (#3311)
rmorshea Oct 6, 2019
717cd1f
imaplib.pyi: Add ssl_context parameter for Python >= 3.3 (#3310)
utkarsh2102 Oct 6, 2019
447691c
imaplib.pyi: Add missing imaplib.IMAP4.enable() (#3314)
utkarsh2102 Oct 7, 2019
7710e92
Add `data` to UserList class, fix UserDict.data type (#3316)
CraftSpider Oct 7, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 16 additions & 29 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,25 @@
dist: xenial
dist: bionic
language: python
python: 3.7

matrix:
jobs:
include:
- name: "pytype"
python: 3.6
env:
- TEST_CMD="./tests/pytype_test.py"
- INSTALL="test"
- name: "mypy"
env:
- TEST_CMD="./tests/mypy_test.py"
- INSTALL="mypy"
- name: "mypy new analyzer"
env:
- TEST_CMD="./tests/mypy_test.py -a"
- INSTALL="mypy"
install: pip install -r requirements-tests-py3.txt
script: ./tests/pytype_test.py
- name: "mypy (typed-ast)"
python: 3.7
install: pip install -U git+git://github.com/python/mypy git+git://github.com/python/typed_ast
script: ./tests/mypy_test.py
- name: "mypy (ast)"
python: 3.8-dev
install: pip install -U git+git://github.com/python/mypy
script: ./tests/mypy_test.py
- name: "mypy self test"
env: TEST_CMD="./tests/mypy_selftest.py"
- name: "mypy self test (new analyzer)"
env:
- NEWSEMANAL=1
- TEST_CMD="./tests/mypy_selftest.py"
script: ./tests/mypy_selftest.py
- name: "check file consistency"
env: TEST_CMD="./tests/check_consistent.py"
script: ./tests/check_consistent.py
- name: "flake8"
env:
- TEST_CMD="flake8"
- INSTALL="test"

install:
- if [[ $INSTALL == 'test' ]]; then pip install -r requirements-tests-py3.txt; fi
- if [[ $INSTALL == 'mypy' ]]; then pip install -U git+git://github.com/python/mypy git+git://github.com/python/typed_ast; fi

script:
- $TEST_CMD
install: pip install -r requirements-tests-py3.txt
script: flake8
29 changes: 19 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ rule is that they should be as concise as possible. Specifically:
* use variable annotations instead of type comments, even for stubs
that target older versions of Python;
* for arguments with a type and a default, use spaces around the `=`.
The code formatter [black](https://github.com/python/black) will format
The code formatter [black](https://github.com/psf/black) will format
stubs according to this standard.

Stub files should only contain information necessary for the type
Expand Down Expand Up @@ -292,6 +292,15 @@ Type variables and aliases you introduce purely for legibility reasons
should be prefixed with an underscore to make it obvious to the reader
they are not part of the stubbed API.

When adding type annotations for context manager classes, annotate
the return type of `__exit__` as bool only if the context manager
sometimes suppresses annotations -- if it sometimes returns `True`
at runtime. If the context manager never suppresses exceptions,
have the return type be either `None` or `Optional[bool]`. If you
are not sure whether exceptions are suppressed or not or if the
context manager is meant to be subclassed, pick `Optional[bool]`.
See https://github.com/python/mypy/issues/7214 for more details.

NOTE: there are stubs in this repository that don't conform to the
style described above. Fixing them is a great starting point for new
contributors.
Expand All @@ -307,8 +316,8 @@ and optionally the lowest minor version, with the exception of the `2and3`
directory which applies to both Python 2 and 3.

For example, stubs in the `3` directory will be applied to all versions of
Python 3, though stubs in the `3.6` directory will only be applied to versions
3.6 and above. However, stubs in the `2` directory will not be applied to
Python 3, though stubs in the `3.7` directory will only be applied to versions
3.7 and above. However, stubs in the `2` directory will not be applied to
Python 3.

It is preferred to use a single stub in the more generic directory that
Expand All @@ -318,7 +327,7 @@ if the given library works on both Python 2 and Python 3, prefer to put your
stubs in the `2and3` directory, unless the types are so different that the stubs
become unreadable that way.

You can use checks like `if sys.version_info >= (3, 4):` to denote new
You can use checks like `if sys.version_info >= (3, 8):` to denote new
functionality introduced in a given Python version or solve type
differences. When doing so, only use one-tuples or two-tuples. This is
because:
Expand All @@ -331,17 +340,17 @@ because:
regardless of the micro version used.

Because of this, if a given functionality was introduced in, say, Python
3.4.4, your check:
3.7.4, your check:

* should be expressed as `if sys.version_info >= (3, 4):`
* should NOT be expressed as `if sys.version_info >= (3, 4, 4):`
* should NOT be expressed as `if sys.version_info >= (3, 5):`
* should be expressed as `if sys.version_info >= (3, 7):`
* should NOT be expressed as `if sys.version_info >= (3, 7, 4):`
* should NOT be expressed as `if sys.version_info >= (3, 8):`

This makes the type checker assume the functionality was also available
in 3.4.0 - 3.4.3, which while *technically* incorrect is relatively
in 3.7.0 - 3.7.3, which while *technically* incorrect is relatively
harmless. This is a strictly better compromise than using the latter
two forms, which would generate false positive errors for correct use
under Python 3.4.4.
under Python 3.7.4.

Note: in its current implementation, typeshed cannot contain stubs for
multiple versions of the same third-party library. Prefer to generate
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ For information on how to use `typeshed`, read below. Information for
contributors can be found in [CONTRIBUTING.md](CONTRIBUTING.md). **Please read
it before submitting pull requests.**

Typeshed supports Python versions 2.7 and 3.4 and up.
Typeshed supports Python versions 2.7 and 3.5 and up.

## Using

Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[tool.black]
line_length = 130
target_version = ["py37"]

[tool.isort]
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
combine_as_imports = true
line_length = 130
10 changes: 6 additions & 4 deletions requirements-tests-py3.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
git+https://github.com/python/mypy.git@master
typed-ast>=1.0.4
flake8==3.6.0
flake8-bugbear==18.8.0
flake8-pyi==18.3.1
pytype>=2019.5.15
black==19.3b0
flake8==3.7.8
flake8-bugbear==19.3.0
flake8-pyi==19.3.0
isort==4.3.21
pytype>=2019.7.30
8 changes: 8 additions & 0 deletions stdlib/2/CGIHTTPServer.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Stubs for CGIHTTPServer (Python 2.7)

from typing import List
import SimpleHTTPServer

class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
cgi_directories: List[str]
def do_POST(self) -> None: ...
12 changes: 7 additions & 5 deletions stdlib/2/ConfigParser.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class _Readable(Protocol):

class RawConfigParser:
_dict: Any
_sections: dict
_defaults: dict
_sections: Dict[Any, Any]
_defaults: Dict[Any, Any]
_optcre: Any
SECTCRE: Any
OPTCRE: Any
Expand Down Expand Up @@ -86,12 +86,14 @@ class RawConfigParser:

class ConfigParser(RawConfigParser):
_KEYCRE: Any
def get(self, section: str, option: str, raw: bool = ..., vars: Optional[dict] = ...) -> Any: ...
def items(self, section: str, raw: bool = ..., vars: Optional[dict] = ...) -> List[Tuple[str, Any]]: ...
def get(self, section: str, option: str, raw: bool = ..., vars: Optional[Dict[Any, Any]] = ...) -> Any: ...
def items(self, section: str, raw: bool = ..., vars: Optional[Dict[Any, Any]] = ...) -> List[Tuple[str, Any]]: ...
def _interpolate(self, section: str, option: str, rawval: Any, vars: Any) -> str: ...
def _interpolation_replace(self, match: Any) -> str: ...

class SafeConfigParser(ConfigParser):
_interpvar_re: Any
def _interpolate(self, section: str, option: str, rawval: Any, vars: Any) -> str: ...
def _interpolate_some(self, option: str, accum: list, rest: str, section: str, map: dict, depth: int) -> None: ...
def _interpolate_some(
self, option: str, accum: List[Any], rest: str, section: str, map: Dict[Any, Any], depth: int,
) -> None: ...
6 changes: 3 additions & 3 deletions stdlib/2/Cookie.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Any, Optional
from typing import Any, Dict, Optional

class CookieError(Exception): ...

class Morsel(dict):
class Morsel(Dict[Any, Any]):
key: Any
def __init__(self): ...
def __setitem__(self, K, V): ...
Expand All @@ -14,7 +14,7 @@ class Morsel(dict):
def js_output(self, attrs: Optional[Any] = ...): ...
def OutputString(self, attrs: Optional[Any] = ...): ...

class BaseCookie(dict):
class BaseCookie(Dict[Any, Any]):
def value_decode(self, val): ...
def value_encode(self, val): ...
def __init__(self, input: Optional[Any] = ...): ...
Expand Down
8 changes: 4 additions & 4 deletions stdlib/2/Queue.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Stubs for Queue (Python 2)

from collections import deque
from typing import Any, TypeVar, Generic, Optional
from typing import Any, Deque, TypeVar, Generic, Optional

_T = TypeVar('_T')

Expand All @@ -15,7 +15,7 @@ class Queue(Generic[_T]):
not_full: Any
all_tasks_done: Any
unfinished_tasks: Any
queue: deque # undocumented
queue: Deque[Any] # undocumented
def __init__(self, maxsize: int = ...) -> None: ...
def task_done(self) -> None: ...
def join(self) -> None: ...
Expand All @@ -27,5 +27,5 @@ class Queue(Generic[_T]):
def get(self, block: bool = ..., timeout: Optional[float] = ...) -> _T: ...
def get_nowait(self) -> _T: ...

class PriorityQueue(Queue): ...
class LifoQueue(Queue): ...
class PriorityQueue(Queue[_T]): ...
class LifoQueue(Queue[_T]): ...
2 changes: 1 addition & 1 deletion stdlib/2/SimpleHTTPServer.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self) -> None: ...
def do_HEAD(self) -> None: ...
def send_head(self) -> Optional[IO[str]]: ...
def list_directory(self, path: Union[str, unicode]) -> Optional[StringIO]: ...
def list_directory(self, path: Union[str, unicode]) -> Optional[StringIO[Any]]: ...
def translate_path(self, path: AnyStr) -> AnyStr: ...
def copyfile(self, source: IO[AnyStr], outputfile: IO[AnyStr]): ...
def guess_type(self, path: Union[str, unicode]) -> str: ...
Expand Down
10 changes: 5 additions & 5 deletions stdlib/2/SocketServer.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NB: SocketServer.pyi and socketserver.pyi must remain consistent!
# Stubs for socketserver

from typing import Any, BinaryIO, Optional, Tuple, Type
from typing import Any, BinaryIO, Optional, Tuple, Type, Text, Union
from socket import SocketType
import sys
import types
Expand All @@ -15,7 +15,7 @@ class BaseServer:
request_queue_size: int
socket_type: int
timeout: Optional[float]
def __init__(self, server_address: Tuple[str, int],
def __init__(self, server_address: Any,
RequestHandlerClass: type) -> None: ...
def fileno(self) -> int: ...
def handle_request(self) -> None: ...
Expand All @@ -38,7 +38,7 @@ class BaseServer:
def __enter__(self) -> BaseServer: ...
def __exit__(self, exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[types.TracebackType]) -> bool: ...
exc_tb: Optional[types.TracebackType]) -> None: ...
if sys.version_info >= (3, 3):
def service_actions(self) -> None: ...

Expand All @@ -54,12 +54,12 @@ class UDPServer(BaseServer):

if sys.platform != 'win32':
class UnixStreamServer(BaseServer):
def __init__(self, server_address: Tuple[str, int],
def __init__(self, server_address: Union[Text, bytes],
RequestHandlerClass: type,
bind_and_activate: bool = ...) -> None: ...

class UnixDatagramServer(BaseServer):
def __init__(self, server_address: Tuple[str, int],
def __init__(self, server_address: Union[Text, bytes],
RequestHandlerClass: type,
bind_and_activate: bool = ...) -> None: ...

Expand Down
2 changes: 1 addition & 1 deletion stdlib/2/UserDict.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ _VT = TypeVar('_VT')
_T = TypeVar('_T')

class UserDict(Dict[_KT, _VT], Generic[_KT, _VT]):
data: Mapping[_KT, _VT]
data: Dict[_KT, _VT]

def __init__(self, initialdata: Mapping[_KT, _VT] = ...) -> None: ...

Expand Down
7 changes: 4 additions & 3 deletions stdlib/2/UserList.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from typing import Iterable, MutableSequence, TypeVar, Union, overload
from typing import Iterable, MutableSequence, TypeVar, Union, overload, List

_T = TypeVar("_T")
_ULT = TypeVar("_ULT", bound=UserList)
_S = TypeVar("_S")

class UserList(MutableSequence[_T]):
data: List[_T]
def insert(self, index: int, object: _T) -> None: ...
@overload
def __setitem__(self, i: int, o: _T) -> None: ...
Expand All @@ -14,5 +15,5 @@ class UserList(MutableSequence[_T]):
@overload
def __getitem__(self, i: int) -> _T: ...
@overload
def __getitem__(self: _ULT, s: slice) -> _ULT: ...
def __getitem__(self: _S, s: slice) -> _S: ...
def sort(self) -> None: ...
Loading