Commit Graph

6 Commits

Author SHA1 Message Date
Sebastian Rittau
c9f19b1d72 Use protocol for FTP.stor* (#3227)
* Use protocol for FTP.stor*

* Reformat ftplib.pyi with black
2019-09-10 14:40:10 -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
Michael Lee
efb67946f8 Use variable annotations everywhere (#2909) 2019-04-13 10:40:52 +02:00
Jelle Zijlstra
37aba00fe8 fix using ZipFile as a ContextManager (#2043) 2018-04-12 12:29:22 -07:00
Chris
875bfe4c2a Allow Any return value for callbacks in retrbinary etc (#1567)
Fixes #1258
2017-08-25 20:40:45 -07:00
David Euresti
514bf736da Add stub for ftplib to 2and3 (#956) 2017-03-14 08:22:05 -07:00