You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Revert "Use Literal for compression in zipfile (#9346)" (#9367)
This reverts commit 034cfab.
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
0 commit comments