35 Commits

Author SHA1 Message Date
Stefano Chiodino
ca45cb21a8 Update zipfile.pyi (#4753) 2020-11-10 12:01:06 +01: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
Selim Belhaouane
8059ea72f8 Fix type for path in ZipFile.extract (#4445) 2020-08-14 15:15:43 -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
Jelle Zijlstra
43e93f803f use _typeshed's Path aliases (#4214) 2020-06-10 20:57:09 -07:00
Shantanu
2d82e1fb8b zipfile.ZipFile: fix fp, extract (#3828)
* zipfile: fp is None in a lot of error cases

* zipfile: pwd can be None in extract

Co-authored-by: hauntsaninja <>
2020-03-06 14:57:06 -08:00
Shantanu
995e83ba2a zipfile: fix various stubs (#3621)
Found using new stub checking script
2020-01-19 11:52:08 +01:00
Shantanu
375e8c1127 zipfile: fix ZipExtFile parameter (#3616)
This was changed in bpo-38334 and backported to Python 3.7.6 and 3.8.1.
2020-01-16 09:03:39 +01:00
hauntsaninja
e10b9c70b2 zipfile: update for py38 (#3572)
* zipfile: add Path, new in py38
* zipfile: use str over Text for py3 branches
* zipfile: add force_zip64 kwarg to open methods
2020-01-06 20:52:46 +01:00
hauntsaninja
64252bfef4 zipfile: fix typo in parameter for PyZipFile (#3573) 2020-01-05 16:12:44 +01:00
Steven Kalt
036a278624 annotated ZipInfo.from_file (#3478)
Closes: #3477
2019-11-23 16:16:25 +01:00
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