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
Annotate unittest.TestCase.skipTest() as no-return
This method unconditionally raises unittest.SkipTest, which ends a test
method early. unittest.TestCase.fail() works similarly, and is already
annotated with NoReturn to indicate this behaviour.
* Revert "`Collection` is `Sized` (#8977)"
This reverts commit 5bbba5d008.
* Revert "typing: remove metaclass from Sized (#9058)"
This reverts commit a3ce512095.
* Add regression test for issue 9296.
- Change the return type of create_connection, start_tls,
connect_accepted_socket, create_unix_connection to Transport
rather than BaseTransport (closes#9199).
- Change the return type of create_datagram_endpoint to
DatagramTransport rather than BaseTransport.
- Change the argument of sendfile to WriteTransport rather than
BaseTransport.
I considered also changing the argument of start_tls to Transport, but
I think that will give false positives for code that implements a custom
transport class that inherits from both ReadTransport and WriteTransport
but not from Transport, and I'm not sure if typing has a way to express
an intersection of types. Since users are not normally expected to
implement transports that may be overthinking things.
* Adapt number types in ast
Since mypy 0.990 type promotions was limited.
This means that complex is not longer promoted to int/float, therefore
we should adapt the types to list all possible types
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: AlexWaygood <alex.waygood@gmail.com>