Skip to content

Commit

Permalink
Bump pyright to v1.1.359
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood committed Apr 22, 2024
1 parent 7859b2a commit 7b3be46
Show file tree
Hide file tree
Showing 18 changed files with 96 additions and 44 deletions.
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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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],

Check failure on line 61 in stdlib/collections/__init__.pyi

View workflow job for this annotation

GitHub Actions / Test typeshed with pyright (Linux, 3.11)

Type annotation for "self" parameter of "__init__" method cannot contain class-scoped type varaiables (reportGeneralTypeIssues)
dict: SupportsKeysAndGetItem[str, _VT],
/,
**kwargs: _VT, # pyright: ignore[reportGeneralTypeIssues] #11780

Check failure on line 64 in stdlib/collections/__init__.pyi

View workflow job for this annotation

GitHub Actions / Test typeshed with pyright (Linux, 3.11)

Unnecessary "# pyright: ignore" rule: "reportGeneralTypeIssues"
) -> 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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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 @@ -182,7 +182,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[reportGeneralTypeIssues] #11780
def __enter__(self) -> _T: ...
def __exit__(self, *exctype: Unused) -> None: ...
async def __aenter__(self) -> _T: ...
Expand All @@ -194,7 +194,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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #11780
) -> None: ...
io: _IOT
@property
def closed(self) -> bool: ...
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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #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[reportGeneralTypeIssues] #11780
name: str | None = None,
*,
expected_type: _ExpectedTypeParam[_T],
Expand Down
6 changes: 3 additions & 3 deletions stubs/redis/redis/asyncio/connection.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class ConnectionPool(Generic[_ConnectionT]):

@overload
def __init__(
self: ConnectionPool[_ConnectionT],
self: ConnectionPool[_ConnectionT], # pyright: ignore[reportGeneralTypeIssues] #11780
connection_class: type[_ConnectionT],
max_connections: int | None = None,
# **kwargs are passed to the constructed connection instances.
Expand All @@ -332,7 +332,7 @@ class BlockingConnectionPool(ConnectionPool[_ConnectionT]):

@overload
def __init__(
self: BlockingConnectionPool[_ConnectionT],
self: BlockingConnectionPool[_ConnectionT], # pyright: ignore[reportGeneralTypeIssues] #11780
max_connections: int,
timeout: int | None,
connection_class: type[_ConnectionT],
Expand All @@ -342,7 +342,7 @@ class BlockingConnectionPool(ConnectionPool[_ConnectionT]):
) -> None: ...
@overload
def __init__(
self: BlockingConnectionPool[_ConnectionT],
self: BlockingConnectionPool[_ConnectionT], # pyright: ignore[reportGeneralTypeIssues] #11780
max_connections: int = 50,
timeout: int | None = 20,
*,
Expand Down
Loading

0 comments on commit 7b3be46

Please sign in to comment.