196 Commits

Author SHA1 Message Date
Sebastian Rittau
d2a7889fe0 Drop support for Python 3.5 (#4675)
Python 3.5 EOL was on 2020-09-30.
2020-11-02 16:18:20 +01:00
Sebastian Rittau
4603728a15 Clean up files with former forced consistency (#4717)
Replace Text with str in Python 3 code
2020-10-27 07:52:35 +01:00
Shantanu
6ff5b88ca7 typeshed: remove crufty comments (#4699)
Co-authored-by: hauntsaninja <>
2020-10-23 09:40:06 +02:00
Utsav
6f943d43ea Added __class_getitem__ (#4695)
Resolves #4682

Co-authored-by: hauntsaninja <>
2020-10-22 14:05:04 -07:00
Kaushal Rohit
021c219e6e concurrent.futures.wait: use _Collection (#4618) 2020-10-06 17:48:40 -07:00
Kaushal Rohit
6e7ac975b4 concurrent.futures.wait: changed Iterable to Sequence (#4597) 2020-10-02 22:51:14 -07:00
Shantanu
e3889c776e pep 484: explicit reexport as intended (#4586)
See discussion on typing-sig.
This doesn't take care of some third_party libraries, will follow up on
those.

Co-authored-by: hauntsaninja <>
2020-09-30 10:04:23 -07:00
Shantanu
48c8939ce6 concurrent.futures: update for py39, minor fixes (#4503)
Note the new parameter doesn't actually exist on the base class, even
though it's documented as that being the case. Asked about it in https://bugs.python.org/issue39349

Co-authored-by: hauntsaninja <>
2020-08-31 22:04:49 +02:00
Jelle Zijlstra
5f9fd3d127 upgrade black version (#4486)
Manually removed a number of trailing commas to prevent black from unnecessarily
exploding some collections.
2020-08-26 18:36:01 +02:00
Shantanu
723fcb368a pathlib.Path.open: bring on the overloads (#4407) 2020-08-21 20:36:43 -07:00
Eric Traut
f46fb7ff59 Added some missing type annotations in stdlib stubs. (#4418)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2020-08-08 20:49:37 +02:00
Jukka Lehtosalo
199b262f63 Add back six.moves.urllib.parse.unquote (Python 2) (#4414)
This was accidentally removed in #4287.
2020-08-07 17:56:54 +01:00
Jukka Lehtosalo
57a1a3937a Add back six.StringIO (Python 2) (#4413)
This was accidentally removed in #4287.
2020-08-07 17:41:48 +01:00
Jukka Lehtosalo
7c444365f2 Add back six.moves.range (Python 2) (#4411)
This was accidentally removed in #4287.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2020-08-07 17:20:34 +01:00
Jukka Lehtosalo
29c71ff52a Add back tornado stubs for Python 2 only (#4412)
Tornado ships with inline annotations, but it no longer is Python 2
compatible. I think that it makes sense to keep the legacy stubs for
Python 2 compatibility, at least for a while longer.

This restores stubs removed in #4321, but moves them to
`third_party/2`.
2020-08-07 08:54:57 -07:00
Sebastian Rittau
06f87e5c92 Simplify pathlib (#4357)
* Enable some branches for Python2 pathlib2
* Define an alias _PathLike, instead of using multiple branches
* Drop a Python 3.4 branch (the Python 2 branch is identical to
  the 3.5+ branch)
* Move Path.__new__ to the top
2020-07-27 06:08:09 -07:00
Jelle Zijlstra
0142a87da8 adjust isort config (#4290)
Fixes #4288.

- Default imports to THIRD_PARTY, so in effect we merge the FIRST_PARTY and THIRD_PARTY stubs. This means import order is no longer affected by whether typing_extensions is installed locally.
- Treat typing_extensions, _typeshed and some others as standard library modules.

Note that isort master is very different from the latest release; we'll have to do something
different if and when the next isort release comes out.
2020-06-29 00:00:21 -07:00
Jelle Zijlstra
5d553c9584 apply black and isort (#4287)
* apply black and isort

* move some type ignores
2020-06-28 13:31:00 -07:00
Sebastian Rittau
89d3a55f1a Preparations for the Big Reformat (#4228)
A few comments between imports were removed or moved to the top of the
import block, due to behavioral differences between black and isort. See
psf/black#251 for details.

In two instances @overloads at the top of the file needed to be moved
due to psf/black#1490.
2020-06-14 07:58:26 -07:00
Jelle Zijlstra
ea577cec1f move OpenTextMode and friends to _typeshed (#4213) 2020-06-10 15:36:21 +02:00
Shantanu
da2aa297a2 pathlib: update for py39 (#4134)
Co-authored-by: hauntsaninja <>
2020-05-28 13:41:53 -07:00
Ilaï Deutel
846d922df2 More precise return types for open(), Path.open(), bz2.open(), etc. (#3371)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
2020-05-28 09:20:23 -07:00
Jelle Zijlstra
ca553cd589 fix type for ipaddress._BaseNetwork.overlaps (#4124) 2020-05-28 13:22:50 +02:00
Ivan Levkivskyi
e199c2e4bc Fix concurrent.futures import for re-export (#4105)
Also update stubtest whitelist as a workaround.
2020-05-27 13:51:01 +01:00
Shantanu
18121d71c8 concurrent.futures: fix top level available objects, add InvalidStateError (#4021)
* concurrent.futures: add InvalidStateError

* concurrent.futures: fix package imports

* asyncio.futures: fix import

* concurrent.futures: fix version availability for BrokenExecutor

* concurrent.futures: make consistent

* concurrent.futures: update whitelist

Co-authored-by: hauntsaninja <>
2020-05-25 15:38:09 -07:00
Shantanu
637dba1beb concurrent.futures: fix BrokenProcessPool base (#3972)
Co-authored-by: hauntsaninja <>
2020-05-11 21:52:55 -07:00
Brian Turek
6e9e059f0c Add return type for pathlib.Path.replace on Python >= 3.8 (#3936) 2020-04-22 01:52:33 +02:00
Debjyoti Biswas
c0938525d8 Add methods for subnet_of and supernet_of (#3851) 2020-03-17 10:06:49 +01:00
Ivan Levkivskyi
aa945cde03 Add six.moves.collections_abc. (#3812) 2020-03-06 00:13:24 +00:00
Ivan Levkivskyi
ca1ca0c14f Move tornado to 2and3 (#3780)
This also uses a trick to avoid `Incompatible with supertype` errors for `get()` etc. that used to have signature like `def get(*args, **kwars): ...` (that btw is used in tornado itself, see https://github.com/tornadoweb/tornado/blob/master/tornado/web.py#L266).
2020-02-26 22:53:48 +00:00
Ivan Levkivskyi
6d33cf3382 Move gflags to 2and3 (#3779)
Move gflags to 2and3
2020-02-26 17:57:50 +00:00
lazytype
cfe69831e9 Include typing for Enum __order__ attribute (#3541)
Based on the behavior here: 0b41a922f9/Lib/enum.py (L91)
the `__order__` attribute should be treated the same as `_order_`
2020-02-21 21:40:33 -08:00
Michael J. Sullivan
7b630ca24a Add unquote_to_bytes to py2 six (#3744) 2020-02-19 23:42:57 +01:00
Benjamin Peterson
2da1b2c426 gflags: Add is_parsed/IsParsed. (#3650) 2020-01-23 08:33:25 +01:00
Anthony Sottile
d0f57d7d38 Fill out more attributes in six (#3589) 2020-01-18 07:41:51 -08:00
Sebastian Rittau
fdeae5d00e Enable --disallow-subclassing-any (#3591)
Closes: #1446
2020-01-08 11:51:44 -08:00
Mickaël Schoentgen
b4d1da03aa Add missing Path.is_mount() introduced in Python 3.7 (#3566) 2020-01-05 16:04:52 +01:00
Jeppe Fihl-Pearson
fed3472e7c Reflect Python 3.8 updates to the pathlib stdlib module (#3568) 2020-01-03 08:47:50 -08:00
Sebastian Rittau
ec7960a8cb Convert namedtuples to class syntax (#3321) 2019-10-20 10:37:33 +02:00
Sebastian Rittau
0501e2b329 Annotations for remaining Python 3.8 additions (#3358)
* Add os.add_dll_directory()
* Add memfd_create() and flags
* Add type annotation to flags
* Add stat_result.st_reparse_tag and flags
* Add ncurses_version
* Add Path.link_to()
* Add Picker.reducer_override()
* Add plistlib.UID
* Add has_dualstack_ipv6() and create_server()
* Add shlex.join()
* Add SSL methods and fields
* Add Python 3.8 statistics functions and classes
* Remove obsolete sys.subversion
* Add sys.unraisablehook
* Add threading.excepthook
* Add get_native_id() and Thread.native_id
* Add Python 3.8 tkinter methods
* Add CLOCK_UPTIME_RAW
* Add SupportsIndex
* Add typing.get_origin() and get_args()
* Add unicodedata.is_normalized
* Add unittest.mock.AsyncMock

Currently this is just an alias for Any like Mock and MagicMock. All of
these classes should probably be sub-classing Any and add their own
methods. See also #3224.

* Add unittest cleanup methods
* Add IsolatedAsyncioTestCase
* Add ElementTree.canonicalize() and C14NWriterTarget
* cProfile.Profile can be used as a context manager
* Add asyncio task name handling
* mmap.flush() now always returns None
* Add posonlyargcount to CodeType
2019-10-14 09:53:48 +02:00
Vasily Zakharov
57384ce033 Revised stubs for geoip2 third party library (#3317) 2019-10-09 19:28:42 -07:00
Sebastian Rittau
07c8675ba5 Remove unused # type: ignore comments (#3325) 2019-10-09 10:27:18 -07:00
Sebastian Rittau
0a426d8a8e Move cryptography from 2 to 2and3 (#3304)
The cryptography stubs are very rudimentary at the moment, but there
is nothing that limits them to just Python 2.

Closes: #3303
2019-10-04 14:11:42 -07:00
Benjamin Peterson
9a1d205f34 cryptography: Return RSAPrivateKeyWithSerialization from generate_private_key. (#3296)
The only extant implementation of generate_private_key returns this more specialized interface.
2019-10-03 01:09:25 +02:00
Sebastian Rittau
c32e1e2280 Enable --disallow-any-generics for stubs (#3288) 2019-10-01 05:31:34 -07:00
Sebastian Rittau
ed4b1de0ad Fix third_party errors with --disallow-any-generics (#3278)
Part of #3267. Together with #3276 this should fix all such problems.
2019-09-30 13:14:01 +02:00
Philippe F
ce0dc8a23d Add proper support for __rtruediv__ on libpath.Path (#3236) 2019-09-17 23:24:42 +02:00
Bouteillebleu
d5a918de7b Add stubs for CGIHTTPServer (#3196)
This commit adds:
* Stubs for CGIHTTPServer in the Python 2 standard library, as requested in #1147.
* Stubs for six.moves.CGIHTTPServer in Python 2, as requested in #22.
2019-08-19 15:34:29 +02:00
Rebecca Chen
fab2ee0d7c Remove unnecessary quotes around forward references. (#3191) 2019-08-16 20:29:32 -07:00
Michael Lee
b294782183 Make most contextmanager __exit__ signatures return Optional[bool] (#3179)
This pull request is a follow-up to https://github.com/python/mypy/issues/7214.

In short, within that mypy issue, we found it would be helpful to
determine between contextmanagers that can "swallow" exceptions vs ones
that can't. This helps prevent some false positive when using flags that
analyze control flow such as `--warn-unreachable`. To do this,
Jelle proposed assuming that only contextmanagers where the `__exit__`
returns `bool` are assumed to swallow exceptions.

This unfortunately required the following typeshed changes:

1. The typing.IO, threading.Lock, and concurrent.futures.Executor
   were all modified so `__exit__` returns `Optional[None]` instead
   of None -- along with all of their subclasses.

   I believe these three types are meant to be subclassed, so I felt
   picking the more general type was correct.

2. There were also a few concrete types (e.g. see socketserver,
   subprocess, ftplib...) that I modified to return `None` -- I checked
   the source code, and these all seem to return None (and don't appear
   to be meant to be subclassable).

3. contextlib.suppress was changed to return bool. I also double-checked
   the unittest modules and modified a subset of those contextmanagers,
   leaving ones like `_AssertRaisesContext` alone.
2019-08-16 16:13:33 -07:00