Commit Graph

39 Commits

Author SHA1 Message Date
Alex Waygood
dd2818a41d Stdlib: add container default values (#9909) 2023-03-21 09:12:34 +01:00
Alex Waygood
9ed39d8796 Use typing_extensions.Self in the stdlib (#9694) 2023-02-09 09:12:13 +00:00
Akuli
37a180ef7b Use octal for mode defaults (#9670) 2023-02-03 19:12:53 +00:00
Alex Waygood
33a62ae42d Add more defaults to the stdlib (#9606)
Continuing work towards #8988.

The first five commits were created using stubdefaulter on various Python versions; the following commits were all created manually by me to fix various problems. The main things this adds that weren't present in #9501 are:

- Defaults in Windows-only modules and Windows-only branches (because I'm running a Windows machine)
- Defaults in non-py311 branches
- Defaults for float parameters
- Defaults for overloads
2023-01-29 01:51:23 +00:00
Jelle Zijlstra
ddfaca3200 stdlib: add argument default values (#9501) 2023-01-18 09:37:34 +01:00
Jukka Lehtosalo
2b20b70cf2 Revert "Use Literal for compression in zipfile (#9346)" (#9367)
This reverts commit 034cfab4d6.

The commit exposed the value of the compression constants, which seem
to be implementation details, in the public API. I don't see anything
in the documentation about the values of the constants such as
`ZIP_STORED`:
https://docs.python.org/3/library/zipfile.html?highlight=zipfile#zipfile.ZipFile

Example where this makes a difference:
```
from typing import Literal
import zipfile

def f1(p: str, compression: int) -> None:
    """Error: compression should have the type Literal[0, 8, 12, 14]"""
    zipfile.ZipFile(p, compression=compression)

def f2(p: str, compression: Literal[0, 8, 12, 14]) -> None:
    """Works, but cryptic and exposes internal implementation details"""
    zipfile.ZipFile(p, compression=compression)
```

The values are of constants need to be explicitly specified if somebody
wants to wrap `zipfipe.ZipFile`, which arguably exposes implementation
details in a problematic fashion.

Here is a real-world example where this caused a regression:
https://github.com/pytorch/vision/blob/main/torchvision/datasets/utils.py#L301
2022-12-16 13:49:16 +00:00
Viicos
034cfab4d6 Use Literal for compression in zipfile (#9346) 2022-12-14 10:46:15 +00:00
Jelle Zijlstra
1d4eed1c9d zipfile: improve bytes handling (#9109)
Technically some uses of `pwd` accept more types, but others
use `isinstance()` to enforce only `bytes`. It seems better to
keep the same type throughout the module.
2022-11-06 21:16:27 -08:00
Alex Waygood
edc0ecd857 Remove Python 3.6 branches from typeshed (#8269) 2022-07-11 10:55:17 +02:00
Sebastian Rittau
214bf15dce Use "all +=" instead of duplicating the branches (#7865) 2022-06-07 13:32:19 +02:00
Jelle Zijlstra
7576805aee zipfile: 3.11 fixes (#7898)
* zipfile: 3.11 fixes

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-05-21 09:22:32 +01:00
Sam Ezeh
bf30fbd3d3 Add ZipFile.mkdir (new in 3.11) (#7769) 2022-05-02 07:32:37 -06:00
Alex Waygood
97a74bc1aa Import from collections.abc wherever possible (#7635) 2022-04-18 12:50:37 +02:00
Alex Waygood
740193a8fc Use TypeAlias where possible for type aliases (#7630) 2022-04-15 18:01:00 -07:00
Alex Waygood
f4ae363b56 stdlib: correct many pos-or-kw arg names in dunder methods (#7451) 2022-03-07 16:40:03 +01:00
Alex Waygood
58e505eeb2 Add __all__ for modules beginning with 'u', 'x', 'w' and 'z' (#7374) 2022-02-23 23:04:21 +01:00
Sebastian Rittau
7179fee2d8 is_zipfile() also accepts bytes paths (#7106)
Use a protocol for is_zipfile(), instead of IO
2022-02-04 21:27:02 -08:00
Alex Waygood
7ccbbdb30a stdlib: Improve many __iter__ and constructor methods (#7112) 2022-02-02 19:14:57 +01:00
Shantanu
b88a6f19cd Upgrade black version (#7089) 2022-01-30 16:27:06 -08:00
Alex Waygood
4e046163b5 Delete many redundant method redefinitions (#6877) 2022-01-09 11:21:03 -08:00
Alex Waygood
a40d79a4e6 Use lowercase type everywhere (#6853) 2022-01-08 16:09:29 +01:00
Alex Waygood
8d5d2520ac Use PEP 585 syntax wherever possible (#6717) 2021-12-28 11:31:43 +01:00
Akuli
a5bc1e037f Add mypy error codes to '# type: ignore' comments (#6379) 2021-11-26 07:07:56 +01:00
Anton Grübel
1af6810b5d Improve typing in zipfile (#5991)
* Improve typing in zipfile

* fix CR suggestions
2021-09-03 13:02:11 +02:00
Shantanu
2d4fcbc81e zipfile: py310 changes, fix open (#5979)
Co-authored-by: hauntsaninja <>
2021-08-28 22:45:01 +02:00
Niklas Gustafsson
918c7d0b84 Add ZipInfo type hint to members argument of ZipFile.extractall (#5936) 2021-08-20 10:43:45 +02:00
Oleg Höfling
64f481189f drop ellipsis assignments from module vars, classvars and instance attrs (#5914)
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
2021-08-11 19:26:58 +02:00
Akuli
ce11072dbe Big diff: use lower-case list and dict (#5888) 2021-08-08 09:26:35 -07:00
Akuli
ee487304d7 Big diff: Use new "|" union syntax (#5872) 2021-08-08 11:05:21 +02:00
Anton Grübel
966858fd4c add missing type hints in zipfile (#5795) 2021-07-20 18:23:19 +02:00
Anton Grübel
8a107464a8 Use _typeshed.Self with __enter__ (#5719) 2021-07-01 23:15:13 +02:00
Jelle Zijlstra
73b4c21cce Make ZipFile.__enter__ return self (#5675) 2021-06-22 17:01:11 +02:00
Sebastian Rittau
2c7bae6901 Use only literal overloads for ZipFile.__init__() (#5504) 2021-05-19 20:54:03 +02:00
Sebastian Rittau
de0c62ffeb zipfile: Replace an instance of IO with a protocol (#5471) 2021-05-18 18:42:59 -07:00
Sebastian Rittau
841a365284 Remove compatibility aliases (#5464)
* Remove compatibility aliases

Remove a few instances of Text

Use aliases from _typeshed

* Remove unused imports
2021-05-15 20:49:20 +03:00
Akuli
17dcea4a68 Akuli and srittau: Remove Python 2 branches from Python 3 stubs (#5461)
* run script and do some manual changes (Akuli)

* do the whole thing manually (srittau)

* merge changes (Akuli)

Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
2021-05-15 15:33:39 +03:00
hatal175
bf5ff49b53 mailbox, mimetypes, unittest, zipfile: stubtest fixes (#5239) 2021-04-21 21:58:01 -07:00
hatal175
c9d996fe55 Various stubtest exceptions (#5227) 2021-04-17 07:03:28 -07:00
Ivan Levkivskyi
16ae4c6120 Re-organize directory structure (#4971)
See discussion in #2491

Co-authored-by: Ivan Levkivskyi <ilevkivskyi@dropbox.com>
2021-01-27 12:00:39 +00:00