A new shade of Black (#11362)

This commit is contained in:
Alex Waygood
2024-02-05 00:38:55 +00:00
committed by GitHub
parent 7a6a749449
commit c49c84f319
76 changed files with 190 additions and 106 deletions

View File

@@ -4,6 +4,7 @@ Tests for `dict.__(r)or__`.
`dict.__or__` and `dict.__ror__` were only added in py39,
hence why these are in a separate file to the other test cases for `dict`.
"""
from __future__ import annotations
import os

View File

@@ -214,8 +214,7 @@ if sys.version_info >= (3, 11):
_BE = TypeVar("_BE", bound=BaseException)
class CustomBaseGroup(BaseExceptionGroup[_BE]):
...
class CustomBaseGroup(BaseExceptionGroup[_BE]): ...
cb1 = CustomBaseGroup("x", [SystemExit()])
assert_type(cb1, CustomBaseGroup[SystemExit])
@@ -276,8 +275,7 @@ if sys.version_info >= (3, 11):
_E = TypeVar("_E", bound=Exception)
class CustomGroup(ExceptionGroup[_E]):
...
class CustomGroup(ExceptionGroup[_E]): ...
CustomGroup("x", [SystemExit()]) # type: ignore
cg1 = CustomGroup("x", [ValueError()])

View File

@@ -54,12 +54,10 @@ round(WithCustomRound2()) # type: ignore
class WithOverloadedRound:
@overload
def __round__(self, ndigits: None = ...) -> str:
...
def __round__(self, ndigits: None = ...) -> str: ...
@overload
def __round__(self, ndigits: int) -> bytes:
...
def __round__(self, ndigits: int) -> bytes: ...
def __round__(self, ndigits: int | None = None) -> str | bytes:
return b"" if ndigits is None else ""

View File

@@ -5,12 +5,10 @@ from concurrent.futures import Future, ThreadPoolExecutor, as_completed
from typing_extensions import assert_type
class Parent:
...
class Parent: ...
class Child(Parent):
...
class Child(Parent): ...
def check_as_completed_covariance() -> None:

View File

@@ -3,6 +3,7 @@
These are all meant to be examples of idiomatic itertools usage,
so they should all type-check without error.
"""
from __future__ import annotations
import collections
@@ -93,13 +94,11 @@ def consume(iterator: Iterator[object], n: int | None = None) -> None:
@overload
def nth(iterable: Iterable[_T], n: int, default: None = None) -> _T | None:
...
def nth(iterable: Iterable[_T], n: int, default: None = None) -> _T | None: ...
@overload
def nth(iterable: Iterable[_T], n: int, default: _T1) -> _T | _T1:
...
def nth(iterable: Iterable[_T], n: int, default: _T1) -> _T | _T1: ...
def nth(iterable: Iterable[object], n: int, default: object = None) -> object:
@@ -108,13 +107,11 @@ def nth(iterable: Iterable[object], n: int, default: object = None) -> object:
@overload
def quantify(iterable: Iterable[object]) -> int:
...
def quantify(iterable: Iterable[object]) -> int: ...
@overload
def quantify(iterable: Iterable[_T], pred: Callable[[_T], bool]) -> int:
...
def quantify(iterable: Iterable[_T], pred: Callable[[_T], bool]) -> int: ...
def quantify(iterable: Iterable[object], pred: Callable[[Any], bool] = bool) -> int:
@@ -125,13 +122,11 @@ def quantify(iterable: Iterable[object], pred: Callable[[Any], bool] = bool) ->
@overload
def first_true(
iterable: Iterable[_T], default: Literal[False] = False, pred: Callable[[_T], bool] | None = None
) -> _T | Literal[False]:
...
) -> _T | Literal[False]: ...
@overload
def first_true(iterable: Iterable[_T], default: _T1, pred: Callable[[_T], bool] | None = None) -> _T | _T1:
...
def first_true(iterable: Iterable[_T], default: _T1, pred: Callable[[_T], bool] | None = None) -> _T | _T1: ...
def first_true(iterable: Iterable[object], default: object = False, pred: Callable[[Any], bool] | None = None) -> object:
@@ -149,13 +144,13 @@ _ExceptionOrExceptionTuple: TypeAlias = Union[Type[BaseException], Tuple[Type[Ba
@overload
def iter_except(func: Callable[[], _T], exception: _ExceptionOrExceptionTuple, first: None = None) -> Iterator[_T]:
...
def iter_except(func: Callable[[], _T], exception: _ExceptionOrExceptionTuple, first: None = None) -> Iterator[_T]: ...
@overload
def iter_except(func: Callable[[], _T], exception: _ExceptionOrExceptionTuple, first: Callable[[], _T1]) -> Iterator[_T | _T1]:
...
def iter_except(
func: Callable[[], _T], exception: _ExceptionOrExceptionTuple, first: Callable[[], _T1]
) -> Iterator[_T | _T1]: ...
def iter_except(
@@ -253,13 +248,11 @@ def before_and_after(predicate: Callable[[_T], bool], it: Iterable[_T]) -> tuple
@overload
def unique_everseen(iterable: Iterable[_HashableT], key: None = None) -> Iterator[_HashableT]:
...
def unique_everseen(iterable: Iterable[_HashableT], key: None = None) -> Iterator[_HashableT]: ...
@overload
def unique_everseen(iterable: Iterable[_T], key: Callable[[_T], Hashable]) -> Iterator[_T]:
...
def unique_everseen(iterable: Iterable[_T], key: Callable[[_T], Hashable]) -> Iterator[_T]: ...
def unique_everseen(iterable: Iterable[_T], key: Callable[[_T], Hashable] | None = None) -> Iterator[_T]:
@@ -336,20 +329,17 @@ if sys.version_info >= (3, 10):
@overload
def grouper(
iterable: Iterable[_T], n: int, *, incomplete: Literal["fill"] = "fill", fillvalue: None = None
) -> Iterator[tuple[_T | None, ...]]:
...
) -> Iterator[tuple[_T | None, ...]]: ...
@overload
def grouper(
iterable: Iterable[_T], n: int, *, incomplete: Literal["fill"] = "fill", fillvalue: _T1
) -> Iterator[tuple[_T | _T1, ...]]:
...
) -> Iterator[tuple[_T | _T1, ...]]: ...
@overload
def grouper(
iterable: Iterable[_T], n: int, *, incomplete: Literal["strict", "ignore"], fillvalue: None = None
) -> Iterator[tuple[_T, ...]]:
...
) -> Iterator[tuple[_T, ...]]: ...
def grouper(
iterable: Iterable[object], n: int, *, incomplete: Literal["fill", "strict", "ignore"] = "fill", fillvalue: object = None