Skip to content

Bump pyright to v1.1.360 #11810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 13 additions & 3 deletions stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 24 additions & 7 deletions stdlib/collections/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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],
/,
Expand All @@ -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]],
/,
Expand Down
4 changes: 2 additions & 2 deletions stdlib/contextlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand All @@ -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: ...

Expand Down
2 changes: 1 addition & 1 deletion stdlib/logging/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
4 changes: 2 additions & 2 deletions stdlib/unittest/mock.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
11 changes: 9 additions & 2 deletions stdlib/weakref.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
3 changes: 2 additions & 1 deletion stubs/PyMySQL/pymysql/connections.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion stubs/WTForms/wtforms/fields/form.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion stubs/WTForms/wtforms/fields/list.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions stubs/WebOb/webob/dec.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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[()] = (),
Expand All @@ -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],
Expand All @@ -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[()] = (),
Expand All @@ -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],
Expand Down
4 changes: 3 additions & 1 deletion stubs/gevent/gevent/_fileobjectcommon.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
4 changes: 3 additions & 1 deletion stubs/gevent/gevent/_util.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion stubs/gevent/gevent/greenlet.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 13 additions & 3 deletions stubs/libsass/sass.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/mock/mock/mock.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions stubs/openpyxl/openpyxl/descriptors/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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],
Expand All @@ -64,15 +64,15 @@ 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],
allow_none: Literal[True],
) -> 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],
Expand Down
10 changes: 5 additions & 5 deletions stubs/openpyxl/openpyxl/descriptors/nested.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -44,15 +44,15 @@ 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],
allow_none: Literal[True],
) -> 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],
Expand Down Expand Up @@ -115,15 +115,15 @@ 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],
allow_none: Literal[True],
) -> 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],
Expand Down
Loading