Upgrade pyright, improve pyright config files (#8072)

This commit is contained in:
Alex Waygood
2022-06-16 18:50:50 +01:00
committed by GitHub
parent a2ef47660a
commit 6b0c8df9ec
12 changed files with 59 additions and 29 deletions

View File

@@ -1,4 +1,5 @@
import sys
from _typeshed import Self
from collections.abc import Callable
from typing import Any, Generic, TypeVar, overload
from typing_extensions import final
@@ -20,7 +21,7 @@ class ProxyType(Generic[_T]): # "weakproxy"
class ReferenceType(Generic[_T]):
__callback__: Callable[[ReferenceType[_T]], Any]
def __init__(self, o: _T, callback: Callable[[ReferenceType[_T]], Any] | None = ...) -> None: ...
def __new__(cls: type[Self], o: _T, callback: Callable[[ReferenceType[_T]], Any] | None = ...) -> Self: ...
def __call__(self) -> _T | None: ...
def __hash__(self) -> int: ...
if sys.version_info >= (3, 9):

View File

@@ -1,5 +1,5 @@
import sys
from _typeshed import SupportsWrite
from _typeshed import Self, SupportsWrite
from collections.abc import Callable
from typing import Any, Generic, TypeVar
from typing_extensions import Literal
@@ -11,7 +11,16 @@ _FuncT = TypeVar("_FuncT", bound=Callable[..., Any])
# These definitions have special processing in mypy
class ABCMeta(type):
__abstractmethods__: frozenset[str]
def __init__(self, name: str, bases: tuple[type, ...], namespace: dict[str, Any]) -> None: ...
if sys.version_info >= (3, 11):
def __new__(
__mcls: type[Self], __name: str, __bases: tuple[type, ...], __namespace: dict[str, Any], **kwargs: Any
) -> Self: ...
else:
# pyright doesn't like the first parameter being called mcls, hence the `pyright: ignore`
def __new__(
mcls: type[Self], name: str, bases: tuple[type, ...], namespace: dict[str, Any], **kwargs: Any # pyright: ignore
) -> Self: ...
def __instancecheck__(cls: ABCMeta, instance: Any) -> Any: ...
def __subclasscheck__(cls: ABCMeta, subclass: Any) -> Any: ...
def _dump_registry(cls: ABCMeta, file: SupportsWrite[str] | None = ...) -> None: ...

View File

@@ -190,7 +190,9 @@ def wstring_at(address: _CVoidConstPLike, size: int = ...) -> str: ...
class _SimpleCData(Generic[_T], _CData):
value: _T
def __init__(self, value: _T = ...) -> None: ...
# The TypeVar can be unsolved here,
# but we can't use overloads without creating many, many mypy false-positive errors
def __init__(self, value: _T = ...) -> None: ... # type: ignore
class c_byte(_SimpleCData[int]): ...

View File

@@ -95,7 +95,8 @@ class CompletedProcess(Generic[_T]):
# and writing all the overloads would be horrific.
stdout: _T
stderr: _T
def __init__(self, args: _CMD, returncode: int, stdout: _T | None = ..., stderr: _T | None = ...) -> None: ...
# type ignore on __init__ because the TypeVar can technically be unsolved, but see comment above
def __init__(self, args: _CMD, returncode: int, stdout: _T | None = ..., stderr: _T | None = ...) -> None: ... # type: ignore
def check_returncode(self) -> None: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...