Commit Graph

29 Commits

Author SHA1 Message Date
Jelle Zijlstra
5d553c9584 apply black and isort (#4287)
* apply black and isort

* move some type ignores
2020-06-28 13:31:00 -07: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
Sebastian Rittau
c32e1e2280 Enable --disallow-any-generics for stubs (#3288) 2019-10-01 05:31:34 -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
g.denis
50f1988650 concurrent: add private classes and exceptions (#3169) 2019-08-07 10:39:15 +02:00
crusaderky
9941616b9e Add mp_context parameter to concurrent.futures.ProcessPoolExecutor (#3078)
Closes #3076
2019-06-20 19:42:26 +02:00
Michael Lee
efb67946f8 Use variable annotations everywhere (#2909) 2019-04-13 10:40:52 +02:00
Sebastian Rittau
006a79220f Flake8 fixes (#2549)
* Fix over-indented continuation lines

* Fix under-indented continuation lines

* Fix whitespace around default operator problems

* Limit line lengths

* Fix inconsistent files
2018-10-24 07:20:53 -07:00
Ville Skyttä
5b2c8dc883 concurrent.futures: Sync with Python 3.7 (#2343) 2018-08-08 08:26:01 -07:00
Daniel Li
1a8455b444 Add thread_name_prefix to ThreadPoolExecutor stub (#2249)
The thread_name_prefix argument of ThreadPoolExecutor.__init__ was added
to the Python 2 backport in agronholm/pythonfutures#64.
2018-06-17 18:33:37 -07:00
Daniel Li
5054465746 Make concurrent.futures stubs identical (#2237)
Make the Python 2 and 3 concurrent.futures stubs identical so fixes get
applied to both.

For example, #1305 and #2233 fixed the same problem at different times,
as did #1078 and #1911.

By making the stubs identical, we apply the fix from #1711 to Python 2.

Fixes #2234.
2018-06-15 10:03:19 -07:00
matthewfranglen
9a6a7a2e75 See #1977: Delete DoneAndNotDoneFutures definition (#1978)
The generic type of the futures provided to the wait method cannot
currently be preserved through this definition. For now deleting the
unused NamedTuple is the best approach.
2018-03-22 07:59:13 -07:00
Daniel Li
2c6296034f Future.set_running_or_notify_cancel returns bool (#1911)
Future.set_running_or_notify_cancel returns a bool, not None. See commit
13bcc79c12, where this problem was fixed
for Python 2.
2018-02-22 09:03:37 -08:00
Josh Staiger
bc2f88d6ee Make Executor.__enter__ self and return types match (#1711)
Specifically, this solves a problem in code such as:

with ThreadPoolExecutor() as p: ...

Where the p variable would be typed as an abstract `Executor`, rather than the specific `ThreadPoolExecutor` as expected.
2017-11-04 13:56:55 -07:00
Martin DeMello
817c270c32 Clean out the pytype blacklist (#1667) 2017-10-24 10:38:34 -07:00
Miguel Gaiowski
a8dea5e05c Update types for ThreadPoolExecutor for py3.6 (#1414)
* Update types for ThreadPoolExecutor for py3.6

* Removed Optional from ThreadPoolExecutor thread_name_prefix argument
2017-06-16 17:06:22 -07:00
Jelle Zijlstra
6c5474ae8c various fixes to asyncio stubs (#1305) 2017-05-23 16:14:29 -07:00
Max
df9df65882 More precise signatures in concurrent.futures (#1262)
* Allow None in concurrent.futures.exception() and set_exception()

* Make Executor.map() signature more precise

* Remove superfluous signatures

* Specify str type for some concurrent.futures constants

* Update concurrent.futures backport

* CR fixes
2017-05-14 13:55:27 -07:00
Richard Hansen
55d4c08a8e Use BaseException for Future.exception() and .set_exception(). (#935)
The concurrent.futures.Future class's set_exception() method might be
called with a BaseException that is not an Exception, so change
set_exception()'s parameter type from Exception to BaseException.  The
exception set via set_exception() is returned by exception(), so
change exception()'s return type from Exception to BaseException.
2017-02-15 08:19:49 -08:00
Lukasz Langa
82b2d8e3bc Fixing flake8 F403, F405 errors 2016-12-20 02:28:12 -08:00
Lukasz Langa
fe0e3744cc Fixing flake8 E261 errors 2016-12-19 22:09:35 -08:00
Lukasz Langa
b84f20a011 Fixing flake8 W errors 2016-12-19 21:52:56 -08:00
Filip Figiel
d60bea14f6 Improve concurrent.futures.wait function stub (#634) 2016-10-26 07:19:24 -07:00
Sebastian Meßmer
93ef68315b Fixed types in stdlib/3/concurrent/futures: (#557)
* Fixed types in stdlib/3/concurrent/futures:
 - Remove private classes from public interface
 - Add missing types

* Remove "generated by stubgen" headers from modified type stubs

* - Use ... as default value
- Fix space formatting

* Replace more default values with '...'

* Use 'None' as default value where specified by documentation

* Use explicit Optional[T] type instead of default value None
2016-09-19 08:13:12 -07:00
David Euresti
cc8799ee36 Make Future a generic, like in python2 (#449) 2016-08-05 11:57:10 -07:00
Guido van Rossum
3a01aeb562 Fix bad syntax in two stubs. 2016-06-30 09:00:13 -07:00
Ben Darnell
57e25550bc concurrent.futures: stubgen
Imports had to be fixed up manually.
2016-04-11 00:27:58 -04:00