mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-30 16:14:24 +08:00
Remove Python 3.7 branches (#11238)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from functools import wraps
|
||||
from functools import cached_property, wraps
|
||||
from typing import Callable, TypeVar
|
||||
from typing_extensions import ParamSpec, assert_type
|
||||
|
||||
@@ -24,26 +23,26 @@ def my_decorator(func: Callable[P, T_co]) -> Callable[P, T_co]:
|
||||
return wrapper
|
||||
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from functools import cached_property
|
||||
class A:
|
||||
def __init__(self, x: int):
|
||||
self.x = x
|
||||
|
||||
class A:
|
||||
def __init__(self, x: int):
|
||||
self.x = x
|
||||
@cached_property
|
||||
def x(self) -> int:
|
||||
return 0
|
||||
|
||||
@cached_property
|
||||
def x(self) -> int:
|
||||
return 0
|
||||
|
||||
assert_type(A(x=1).x, int)
|
||||
assert_type(A(x=1).x, int)
|
||||
|
||||
class B:
|
||||
@cached_property
|
||||
def x(self) -> int:
|
||||
return 0
|
||||
|
||||
def check_cached_property_settable(x: int) -> None:
|
||||
b = B()
|
||||
assert_type(b.x, int)
|
||||
b.x = x
|
||||
assert_type(b.x, int)
|
||||
class B:
|
||||
@cached_property
|
||||
def x(self) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
def check_cached_property_settable(x: int) -> None:
|
||||
b = B()
|
||||
assert_type(b.x, int)
|
||||
b.x = x
|
||||
assert_type(b.x, int)
|
||||
|
||||
@@ -298,25 +298,23 @@ def polynomial_derivative(coefficients: Sequence[float]) -> list[float]:
|
||||
return list(map(operator.mul, coefficients, powers))
|
||||
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
|
||||
def nth_combination(iterable: Iterable[_T], r: int, index: int) -> tuple[_T, ...]:
|
||||
"Equivalent to list(combinations(iterable, r))[index]"
|
||||
pool = tuple(iterable)
|
||||
n = len(pool)
|
||||
c = math.comb(n, r)
|
||||
if index < 0:
|
||||
index += c
|
||||
if index < 0 or index >= c:
|
||||
raise IndexError
|
||||
result: list[_T] = []
|
||||
while r:
|
||||
c, n, r = c * r // n, n - 1, r - 1
|
||||
while index >= c:
|
||||
index -= c
|
||||
c, n = c * (n - r) // n, n - 1
|
||||
result.append(pool[-1 - n])
|
||||
return tuple(result)
|
||||
def nth_combination(iterable: Iterable[_T], r: int, index: int) -> tuple[_T, ...]:
|
||||
"Equivalent to list(combinations(iterable, r))[index]"
|
||||
pool = tuple(iterable)
|
||||
n = len(pool)
|
||||
c = math.comb(n, r)
|
||||
if index < 0:
|
||||
index += c
|
||||
if index < 0 or index >= c:
|
||||
raise IndexError
|
||||
result: list[_T] = []
|
||||
while r:
|
||||
c, n, r = c * r // n, n - 1, r - 1
|
||||
while index >= c:
|
||||
index -= c
|
||||
c, n = c * (n - r) // n, n - 1
|
||||
result.append(pool[-1 - n])
|
||||
return tuple(result)
|
||||
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
|
||||
@@ -13,5 +13,4 @@ from zipfile import * # noqa: F403
|
||||
if sys.version_info >= (3, 9):
|
||||
x: Annotated[int, 42] # noqa: F405
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
p: Path # noqa: F405
|
||||
p: Path # noqa: F405
|
||||
|
||||
Reference in New Issue
Block a user