Commit Graph

23 Commits

Author SHA1 Message Date
Sebastian Rittau
4770059894 Add missing ZipFile constructor arguments (#3414)
Closes: #3413
2019-10-29 19:46:31 -07:00
Guido van Rossum
b336182b69 Fix some errors with --disallow-any-generics (#3276)
See #3267. Covers all of stdlib/2and3.
2019-09-29 09:15:27 -07:00
Benjamin Peterson
ce0f5b226f zipfile.ZipFile: Add start_dir attribute. (#3203) 2019-08-23 08:46:16 +02: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
Rune Tynan
15b7cdaf40 Implement ZipExtFile in the zipfile type stubs (#3074) 2019-08-10 13:25:03 -07:00
Maarten ter Huurne
32ee49c79c Add zipfile.ZipFile.filename (#3104) 2019-07-25 11:26:39 +02:00
Michael Lee
efb67946f8 Use variable annotations everywhere (#2909) 2019-04-13 10:40:52 +02:00
Michael J. Sullivan
f343150a6d Make ZipFile.NameToInfo use Text as the key type (#2736)
This makes it match ZipInfo.filename and also actual behavior.
2019-01-10 20:32:18 -06:00
Alex Sarkesian
893089d143 Add stubs to classes in zipfile to better enable subclassing (#2707) 2019-01-05 10:43:26 -08:00
Maxim Kurnikov
172b384e23 zipfile.ZipInfo.__init__ is the same on 2/3 (#2628) 2018-11-23 18:46:57 -08:00
PRAJWAL M
b33738e042 Add is_dir method to ZipInfo class (#2554) 2018-10-25 17:55:39 +02:00
tikki
5a1ea5efb2 Minor fixes for zipfile (#2360)
* Add `is_dir` to `ZipFile`

* Allow `pathlib.Path` for `is_zipfile`
2018-08-06 09:48:53 -07:00
strager
e404bc7cd6 Allow pathlib.Path in zipfile.ZipFile (#2238)
`zipfile.ZipFile` is typed to accept `Text` for local and archive file
paths. In Python 3.6, several `ZipFile` methods accept `pathlib.Path`
objects, not just `str` objects. Generalize `ZipFile`'s methods so code
using `pathlib.Path` with `ZipFile` type-checks.

I verified (using my own project) that the following methods work with
os.PurePath at runtime on CPython 3.6:

* zipfile.ZipInfo.__init__
* zipfile.ZipInfo.extractall
* zipfile.ZipInfo.write
2018-06-18 08:29:23 -07:00
Jelle Zijlstra
37aba00fe8 fix using ZipFile as a ContextManager (#2043) 2018-04-12 12:29:22 -07:00
Josh Holland
162d884d32 Make zipfile accept Text, not str (#1826) 2018-03-17 22:33:29 -07:00
Salvo 'LtWorf' Tomaselli
c8c4a8f208 Added filelist attribute to ZipFile (#1798) 2018-01-02 10:18:03 -08:00
Jelle Zijlstra
6f6fa428ce fix some issues found by stubcheck (#1303)
- ThreadError exists (undocumented) on Python 3. It's an alias for _thread.error,
  but making it a separate exception seems fine.
- zipfile.error is an alias for BadZipFile on both Python versions.
- zlib.Compress and Decompress are not actually accessible at runtime.
2017-05-23 12:44:35 -07:00
Lukasz Langa
5f416fae64 Add missing List imports. 2016-12-21 01:06:52 -08:00
David Percy
9fa6c994a3 Fix zipfile getinfo return type (#678) 2016-11-10 11:08:57 -08:00
Guido van Rossum
47f2746526 Fix the definitions of BadZip{f,F}ile. (#432)
In 2.7, only BadZipfile exists. In 3.x, both exist.
2016-08-02 09:04:45 -07:00
Guido van Rossum
39325bf159 Mypy now supports sys.platform and sys.version_info checks (#410) 2016-07-27 13:25:29 -07:00
alvarocaceres
f7b35bc8be Remove line continuations to help pytype parse (#390) 2016-07-22 10:55:42 -07:00
Valérian Rousset
8ef221c162 add zipfile for py2 (#345) 2016-07-15 05:55:20 -07:00