Bump pyright to v1.1.360 (#11810)

This commit is contained in:
Alex Waygood
2024-04-24 13:09:16 +01:00
committed by GitHub
parent 29db988c0a
commit d0f2be92ab
20 changed files with 100 additions and 46 deletions

View File

@@ -7,7 +7,7 @@ flake8-noqa==1.4.0 # must match .pre-commit-config.yaml
flake8-pyi==24.4.1 # must match .pre-commit-config.yaml
mypy==1.9.0
pre-commit-hooks==4.5.0 # must match .pre-commit-config.yaml
pyright==1.1.358
pyright==1.1.360
pytype==2024.4.11; platform_system != "Windows" and python_version < "3.12"
ruff==0.3.7 # must match .pre-commit-config.yaml

View File

@@ -1031,15 +1031,25 @@ class dict(MutableMapping[_KT, _VT]):
@overload
def __init__(self) -> None: ...
@overload
def __init__(self: dict[str, _VT], **kwargs: _VT) -> None: ...
def __init__(self: dict[str, _VT], **kwargs: _VT) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780
@overload
def __init__(self, map: SupportsKeysAndGetItem[_KT, _VT], /) -> None: ...
@overload
def __init__(self: dict[str, _VT], map: SupportsKeysAndGetItem[str, _VT], /, **kwargs: _VT) -> None: ...
def __init__(
self: dict[str, _VT], # pyright: ignore[reportInvalidTypeVarUse] #11780
map: SupportsKeysAndGetItem[str, _VT],
/,
**kwargs: _VT,
) -> None: ...
@overload
def __init__(self, iterable: Iterable[tuple[_KT, _VT]], /) -> None: ...
@overload
def __init__(self: dict[str, _VT], iterable: Iterable[tuple[str, _VT]], /, **kwargs: _VT) -> None: ...
def __init__(
self: dict[str, _VT], # pyright: ignore[reportInvalidTypeVarUse] #11780
iterable: Iterable[tuple[str, _VT]],
/,
**kwargs: _VT,
) -> None: ...
# Next two overloads are for dict(string.split(sep) for string in iterable)
# Cannot be Iterable[Sequence[_T]] or otherwise dict(["foo", "bar", "baz"]) is not an error
@overload

View File

@@ -51,15 +51,27 @@ class UserDict(MutableMapping[_KT, _VT]):
@overload
def __init__(self, dict: None = None, /) -> None: ...
@overload
def __init__(self: UserDict[str, _VT], dict: None = None, /, **kwargs: _VT) -> None: ...
def __init__(
self: UserDict[str, _VT], dict: None = None, /, **kwargs: _VT # pyright: ignore[reportInvalidTypeVarUse] #11780
) -> None: ...
@overload
def __init__(self, dict: SupportsKeysAndGetItem[_KT, _VT], /) -> None: ...
@overload
def __init__(self: UserDict[str, _VT], dict: SupportsKeysAndGetItem[str, _VT], /, **kwargs: _VT) -> None: ...
def __init__(
self: UserDict[str, _VT], # pyright: ignore[reportInvalidTypeVarUse] #11780
dict: SupportsKeysAndGetItem[str, _VT],
/,
**kwargs: _VT,
) -> None: ...
@overload
def __init__(self, iterable: Iterable[tuple[_KT, _VT]], /) -> None: ...
@overload
def __init__(self: UserDict[str, _VT], iterable: Iterable[tuple[str, _VT]], /, **kwargs: _VT) -> None: ...
def __init__(
self: UserDict[str, _VT], # pyright: ignore[reportInvalidTypeVarUse] #11780
iterable: Iterable[tuple[str, _VT]],
/,
**kwargs: _VT,
) -> None: ...
@overload
def __init__(self: UserDict[str, str], iterable: Iterable[list[str]], /) -> None: ...
@overload
@@ -389,16 +401,21 @@ class defaultdict(dict[_KT, _VT]):
@overload
def __init__(self) -> None: ...
@overload
def __init__(self: defaultdict[str, _VT], **kwargs: _VT) -> None: ...
def __init__(self: defaultdict[str, _VT], **kwargs: _VT) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780
@overload
def __init__(self, default_factory: Callable[[], _VT] | None, /) -> None: ...
@overload
def __init__(self: defaultdict[str, _VT], default_factory: Callable[[], _VT] | None, /, **kwargs: _VT) -> None: ...
def __init__(
self: defaultdict[str, _VT], # pyright: ignore[reportInvalidTypeVarUse] #11780
default_factory: Callable[[], _VT] | None,
/,
**kwargs: _VT,
) -> None: ...
@overload
def __init__(self, default_factory: Callable[[], _VT] | None, map: SupportsKeysAndGetItem[_KT, _VT], /) -> None: ...
@overload
def __init__(
self: defaultdict[str, _VT],
self: defaultdict[str, _VT], # pyright: ignore[reportInvalidTypeVarUse] #11780
default_factory: Callable[[], _VT] | None,
map: SupportsKeysAndGetItem[str, _VT],
/,
@@ -408,7 +425,7 @@ class defaultdict(dict[_KT, _VT]):
def __init__(self, default_factory: Callable[[], _VT] | None, iterable: Iterable[tuple[_KT, _VT]], /) -> None: ...
@overload
def __init__(
self: defaultdict[str, _VT],
self: defaultdict[str, _VT], # pyright: ignore[reportInvalidTypeVarUse] #11780
default_factory: Callable[[], _VT] | None,
iterable: Iterable[tuple[str, _VT]],
/,

View File

@@ -183,7 +183,7 @@ if sys.version_info >= (3, 10):
@overload
def __init__(self: nullcontext[None], enter_result: None = None) -> None: ...
@overload
def __init__(self: nullcontext[_T], enter_result: _T) -> None: ...
def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780
def __enter__(self) -> _T: ...
def __exit__(self, *exctype: Unused) -> None: ...
async def __aenter__(self) -> _T: ...
@@ -195,7 +195,7 @@ else:
@overload
def __init__(self: nullcontext[None], enter_result: None = None) -> None: ...
@overload
def __init__(self: nullcontext[_T], enter_result: _T) -> None: ...
def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780
def __enter__(self) -> _T: ...
def __exit__(self, *exctype: Unused) -> None: ...

View File

@@ -597,7 +597,7 @@ class StreamHandler(Handler, Generic[_StreamT]):
@overload
def __init__(self: StreamHandler[TextIO], stream: None = None) -> None: ...
@overload
def __init__(self: StreamHandler[_StreamT], stream: _StreamT) -> None: ...
def __init__(self: StreamHandler[_StreamT], stream: _StreamT) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780
def setStream(self, stream: _StreamT) -> _StreamT | None: ...
if sys.version_info >= (3, 11):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...

View File

@@ -188,7 +188,7 @@ class _patch(Generic[_T]):
# but that's impossible with the current type system.
if sys.version_info >= (3, 10):
def __init__(
self: _patch[_T],
self: _patch[_T], # pyright: ignore[reportInvalidTypeVarUse] #11780
getter: Callable[[], Any],
attribute: str,
new: _T,
@@ -203,7 +203,7 @@ class _patch(Generic[_T]):
) -> None: ...
else:
def __init__(
self: _patch[_T],
self: _patch[_T], # pyright: ignore[reportInvalidTypeVarUse] #11780
getter: Callable[[], Any],
attribute: str,
new: _T,

View File

@@ -51,10 +51,17 @@ class WeakValueDictionary(MutableMapping[_KT, _VT]):
@overload
def __init__(self) -> None: ...
@overload
def __init__(self: WeakValueDictionary[_KT, _VT], other: Mapping[_KT, _VT] | Iterable[tuple[_KT, _VT]], /) -> None: ...
def __init__(
self: WeakValueDictionary[_KT, _VT], # pyright: ignore[reportInvalidTypeVarUse] #11780
other: Mapping[_KT, _VT] | Iterable[tuple[_KT, _VT]],
/,
) -> None: ...
@overload
def __init__(
self: WeakValueDictionary[str, _VT], other: Mapping[str, _VT] | Iterable[tuple[str, _VT]] = (), /, **kwargs: _VT
self: WeakValueDictionary[str, _VT], # pyright: ignore[reportInvalidTypeVarUse] #11780
other: Mapping[str, _VT] | Iterable[tuple[str, _VT]] = (),
/,
**kwargs: _VT,
) -> None: ...
def __len__(self) -> int: ...
def __getitem__(self, key: _KT) -> _VT: ...

View File

@@ -124,7 +124,8 @@ class Connection(Generic[_C]):
) -> None: ...
@overload
def __init__(
self: Connection[_C], # different between overloads
# different between overloads:
self: Connection[_C], # pyright: ignore[reportInvalidTypeVarUse] #11780
*,
host: str | None = None,
user: Incomplete | None = None,

View File

@@ -12,7 +12,7 @@ class FormField(Field, Generic[_BoundFormT]):
form: _BoundFormT
separator: str
def __init__(
self: FormField[_BoundFormT],
self: FormField[_BoundFormT], # pyright: ignore[reportInvalidTypeVarUse] #11780
form_class: type[_BoundFormT],
label: str | None = None,
validators: None = None,

View File

@@ -15,7 +15,7 @@ class FieldList(Field, Generic[_BoundFieldT]):
entries: list[_BoundFieldT]
object_data: Iterable[Any]
def __init__(
self: FieldList[_BoundFieldT],
self: FieldList[_BoundFieldT], # pyright: ignore[reportInvalidTypeVarUse] #11780
# because of our workaround we need to accept Field as well
unbound_field: UnboundField[_BoundFieldT] | _BoundFieldT,
label: str | None = None,

View File

@@ -45,7 +45,7 @@ class wsgify(Generic[_RequestT_contra, _P]):
) -> None: ...
@overload
def __init__(
self: wsgify[_RequestT_contra, []],
self: wsgify[_RequestT_contra, []], # pyright: ignore[reportInvalidTypeVarUse] #11780
func: _RequestHandler[_RequestT_contra, []] | None,
RequestClass: type[_RequestT_contra],
args: tuple[()] = (),
@@ -54,7 +54,7 @@ class wsgify(Generic[_RequestT_contra, _P]):
) -> None: ...
@overload
def __init__(
self: wsgify[_RequestT_contra, []],
self: wsgify[_RequestT_contra, []], # pyright: ignore[reportInvalidTypeVarUse] #11780
func: _RequestHandler[_RequestT_contra, []] | None = None,
*,
RequestClass: type[_RequestT_contra],
@@ -74,7 +74,7 @@ class wsgify(Generic[_RequestT_contra, _P]):
) -> None: ...
@overload
def __init__(
self: wsgify[_RequestT_contra, [_AppT_contra]],
self: wsgify[_RequestT_contra, [_AppT_contra]], # pyright: ignore[reportInvalidTypeVarUse] #11780
func: _Middleware[_RequestT_contra, _AppT_contra, []] | None,
RequestClass: type[_RequestT_contra],
args: tuple[()] = (),
@@ -84,7 +84,7 @@ class wsgify(Generic[_RequestT_contra, _P]):
) -> None: ...
@overload
def __init__(
self: wsgify[_RequestT_contra, [_AppT_contra]],
self: wsgify[_RequestT_contra, [_AppT_contra]], # pyright: ignore[reportInvalidTypeVarUse] #11780
func: _Middleware[_RequestT_contra, _AppT_contra, []] | None = None,
*,
RequestClass: type[_RequestT_contra],

View File

@@ -80,7 +80,9 @@ class OpenDescriptor(Generic[_IOT]):
def buffer_size_for_stream(cls, stream: object) -> int: ...
class FileObjectBase(Generic[_IOT, AnyStr]):
def __init__(self: FileObjectBase[_IOT, AnyStr], descriptor: OpenDescriptor[_IOT]) -> None: ...
def __init__(
self: FileObjectBase[_IOT, AnyStr], descriptor: OpenDescriptor[_IOT] # pyright: ignore[reportInvalidTypeVarUse] #11780
) -> None: ...
io: _IOT
@property
def closed(self) -> bool: ...

View File

@@ -31,7 +31,9 @@ class Lazy(Generic[_T]):
class readproperty(Generic[_T]):
func: Callable[[Any], _T]
def __init__(self: readproperty[_T], func: Callable[[Any], _T]) -> None: ...
def __init__(
self: readproperty[_T], func: Callable[[Any], _T] # pyright: ignore[reportInvalidTypeVarUse] #11780
) -> None: ...
@overload
def __get__(self, inst: None, class_: type[object]) -> Self: ...
@overload

View File

@@ -19,7 +19,12 @@ class Greenlet(greenlet.greenlet, Generic[_P, _T]):
kwargs: dict[str, Any]
value: _T | None
@overload
def __init__(self: Greenlet[_P, _T], run: Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs) -> None: ...
def __init__(
self: Greenlet[_P, _T], # pyright: ignore[reportInvalidTypeVarUse] #11780
run: Callable[_P, _T],
*args: _P.args,
**kwargs: _P.kwargs,
) -> None: ...
@overload
def __init__(self: Greenlet[[], None]) -> None: ...
@readproperty

View File

@@ -160,15 +160,25 @@ class SassMap(Mapping[_KT, _VT_co]):
@overload
def __init__(self) -> None: ...
@overload
def __init__(self: SassMap[str, _VT_co], **kwargs: _VT_co) -> None: ...
def __init__(self: SassMap[str, _VT_co], **kwargs: _VT_co) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780
@overload
def __init__(self, map: SupportsKeysAndGetItem[_KT, _VT_co], /) -> None: ...
@overload
def __init__(self: SassMap[str, _VT_co], map: SupportsKeysAndGetItem[str, _VT_co], /, **kwargs: _VT_co) -> None: ...
def __init__(
self: SassMap[str, _VT_co], # pyright: ignore[reportInvalidTypeVarUse] #11780
map: SupportsKeysAndGetItem[str, _VT_co],
/,
**kwargs: _VT_co,
) -> None: ...
@overload
def __init__(self, iterable: Iterable[tuple[_KT, _VT_co]], /) -> None: ...
@overload
def __init__(self: SassMap[str, _VT_co], iterable: Iterable[tuple[str, _VT_co]], /, **kwargs: _VT_co) -> None: ...
def __init__(
self: SassMap[str, _VT_co], # pyright: ignore[reportInvalidTypeVarUse] #11780
iterable: Iterable[tuple[str, _VT_co]],
/,
**kwargs: _VT_co,
) -> None: ...
def __getitem__(self, key: _KT) -> _VT_co: ...
def __iter__(self) -> Iterator[_KT]: ...
def __len__(self) -> int: ...

View File

@@ -177,7 +177,7 @@ class _patch(Generic[_T]):
kwargs: Mapping[str, Any]
additional_patchers: Any
def __init__(
self: _patch[_T],
self: _patch[_T], # pyright: ignore[reportInvalidTypeVarUse] #11780
getter: Callable[[], Any],
attribute: str,
new: _T,

View File

@@ -36,7 +36,7 @@ class Typed(Descriptor[_T], Generic[_T, _N]):
@overload
def __init__(
self: Typed[_T, Literal[True]],
self: Typed[_T, Literal[True]], # pyright: ignore[reportInvalidTypeVarUse] #11780
name: str | None = None,
*,
expected_type: _ExpectedTypeParam[_T],
@@ -45,7 +45,7 @@ class Typed(Descriptor[_T], Generic[_T, _N]):
) -> None: ...
@overload
def __init__(
self: Typed[_T, Literal[False]],
self: Typed[_T, Literal[False]], # pyright: ignore[reportInvalidTypeVarUse] #11780
name: str | None = None,
*,
expected_type: _ExpectedTypeParam[_T],
@@ -64,7 +64,7 @@ class Typed(Descriptor[_T], Generic[_T, _N]):
class Convertible(Typed[_T, _N]):
@overload
def __init__(
self: Convertible[_T, Literal[True]],
self: Convertible[_T, Literal[True]], # pyright: ignore[reportInvalidTypeVarUse] #11780
name: str | None = None,
*,
expected_type: _ExpectedTypeParam[_T],
@@ -72,7 +72,7 @@ class Convertible(Typed[_T, _N]):
) -> None: ...
@overload
def __init__(
self: Convertible[_T, Literal[False]],
self: Convertible[_T, Literal[False]], # pyright: ignore[reportInvalidTypeVarUse] #11780
name: str | None = None,
*,
expected_type: _ExpectedTypeParam[_T],

View File

@@ -25,7 +25,7 @@ class Nested(Descriptor[_T]):
namespace: str | None
# In usage, "Nested" is closed to "Typed" than "Descriptor", but doesn't use allow_none
def __init__(
self: Nested[_T],
self: Nested[_T], # pyright: ignore[reportInvalidTypeVarUse] #11780
name: str | None = None,
*,
expected_type: _ExpectedTypeParam[_T],
@@ -44,7 +44,7 @@ class Nested(Descriptor[_T]):
class NestedValue(Nested[_T], Convertible[_T, _N]): # type: ignore[misc]
@overload
def __init__(
self: NestedValue[_T, Literal[True]],
self: NestedValue[_T, Literal[True]], # pyright: ignore[reportInvalidTypeVarUse] #11780
name: str | None = None,
*,
expected_type: _ExpectedTypeParam[_T],
@@ -52,7 +52,7 @@ class NestedValue(Nested[_T], Convertible[_T, _N]): # type: ignore[misc]
) -> None: ...
@overload
def __init__(
self: NestedValue[_T, Literal[False]],
self: NestedValue[_T, Literal[False]], # pyright: ignore[reportInvalidTypeVarUse] #11780
name: str | None = None,
*,
expected_type: _ExpectedTypeParam[_T],
@@ -115,7 +115,7 @@ class NestedValue(Nested[_T], Convertible[_T, _N]): # type: ignore[misc]
class NestedText(NestedValue[_T, _N]):
@overload
def __init__(
self: NestedText[_T, Literal[True]],
self: NestedText[_T, Literal[True]], # pyright: ignore[reportInvalidTypeVarUse] #11780
name: str | None = None,
*,
expected_type: _ExpectedTypeParam[_T],
@@ -123,7 +123,7 @@ class NestedText(NestedValue[_T, _N]):
) -> None: ...
@overload
def __init__(
self: NestedText[_T, Literal[False]],
self: NestedText[_T, Literal[False]], # pyright: ignore[reportInvalidTypeVarUse] #11780
name: str | None = None,
*,
expected_type: _ExpectedTypeParam[_T],

View File

@@ -308,7 +308,7 @@ class ConnectionPool(Generic[_ConnectionT]):
@overload
def __init__(
self: ConnectionPool[_ConnectionT],
self: ConnectionPool[_ConnectionT], # pyright: ignore[reportInvalidTypeVarUse] #11780
connection_class: type[_ConnectionT],
max_connections: int | None = None,
# **kwargs are passed to the constructed connection instances.
@@ -332,7 +332,7 @@ class BlockingConnectionPool(ConnectionPool[_ConnectionT]):
@overload
def __init__(
self: BlockingConnectionPool[_ConnectionT],
self: BlockingConnectionPool[_ConnectionT], # pyright: ignore[reportInvalidTypeVarUse] #11780
max_connections: int,
timeout: int | None,
connection_class: type[_ConnectionT],
@@ -342,7 +342,7 @@ class BlockingConnectionPool(ConnectionPool[_ConnectionT]):
) -> None: ...
@overload
def __init__(
self: BlockingConnectionPool[_ConnectionT],
self: BlockingConnectionPool[_ConnectionT], # pyright: ignore[reportInvalidTypeVarUse] #11780
max_connections: int = 50,
timeout: int | None = 20,
*,

View File

@@ -26,7 +26,7 @@ class postfork(Generic[_P, _T]):
@overload
def __init__(self: postfork[..., Any], f: int) -> None: ...
@overload
def __init__(self: postfork[_P, _T], f: Callable[_P, _T]) -> None: ...
def __init__(self: postfork[_P, _T], f: Callable[_P, _T]) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780
@overload
def __call__(self, f: Callable[_P2, _T2], /) -> postfork[_P2, _T2]: ...
@overload
@@ -70,7 +70,7 @@ class mulefunc(Generic[_P, _T]):
@overload
def __init__(self: mulefunc[..., Any], f: int) -> None: ...
@overload
def __init__(self: mulefunc[_P, _T], f: Callable[_P, _T]) -> None: ...
def __init__(self: mulefunc[_P, _T], f: Callable[_P, _T]) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780
def real_call(self, *args: _P.args, **kwargs: _P.kwargs) -> None: ...
@overload
def __call__(self, f: Callable[_P2, _T2], /) -> mulefunc[_P2, _T2]: ...