mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
Upgrade pyright, improve pyright config files (#8072)
This commit is contained in:
6
.github/workflows/tests.yml
vendored
6
.github/workflows/tests.yml
vendored
@@ -77,7 +77,7 @@ jobs:
|
||||
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
|
||||
fail-fast: false
|
||||
env:
|
||||
PYRIGHT_VERSION: 1.1.248 # Must match pyright_test.py.
|
||||
PYRIGHT_VERSION: 1.1.254 # Must match pyright_test.py.
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: jakebailey/pyright-action@v1
|
||||
@@ -85,14 +85,14 @@ jobs:
|
||||
version: ${{ env.PYRIGHT_VERSION }}
|
||||
python-platform: ${{ matrix.python-platform }}
|
||||
python-version: ${{ matrix.python-version }}
|
||||
no-comments: ${{ matrix.python-version != '3.9' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy.
|
||||
no-comments: ${{ matrix.python-version != '3.10' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy.
|
||||
project: ./pyrightconfig.stricter.json
|
||||
- uses: jakebailey/pyright-action@v1
|
||||
with:
|
||||
version: ${{ env.PYRIGHT_VERSION }}
|
||||
python-platform: ${{ matrix.python-platform }}
|
||||
python-version: ${{ matrix.python-version }}
|
||||
no-comments: ${{ matrix.python-version != '3.9' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy.
|
||||
no-comments: ${{ matrix.python-version != '3.10' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy.
|
||||
|
||||
stubtest-third-party:
|
||||
name: Check third party stubs with stubtest
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"strictListInference": true,
|
||||
"strictDictionaryInference": true,
|
||||
"strictParameterNoneValue": true,
|
||||
"strictSetInference": true,
|
||||
"reportFunctionMemberAccess": "error",
|
||||
"reportMissingModuleSource": "none",
|
||||
"reportMissingTypeStubs": "error",
|
||||
@@ -40,16 +41,18 @@
|
||||
"reportUnboundVariable": "error",
|
||||
"reportInvalidStubStatement": "error",
|
||||
"reportInvalidTypeVarUse": "error",
|
||||
"reportPropertyTypeMismatch": "none",
|
||||
"reportSelfClsParameterName": "error",
|
||||
"reportUnsupportedDunderAll": "error",
|
||||
// Incompatible overrides are out of typeshed's control as they are
|
||||
// inherited from the implementation.
|
||||
"reportInconsistentConstructor": "error",
|
||||
"reportTypeCommentUsage": "error",
|
||||
"reportUnnecessaryComparison": "error",
|
||||
// Incompatible overrides and property type mismatches are out of typeshed's control
|
||||
// as they are inherited from the implementation.
|
||||
"reportPropertyTypeMismatch": "none",
|
||||
"reportIncompatibleMethodOverride": "none",
|
||||
"reportIncompatibleVariableOverride": "none",
|
||||
// Overlapping overloads cannot be enabled at this time because
|
||||
// of the "fractions.Fraction.__pow__" method and "tasks.gather" function.
|
||||
// Mypy's overlapping overload logic misses these issues (see mypy
|
||||
// issue #10143 and #10157).
|
||||
// Overlapping overloads are often necessary in a stub, meaning pyright's check
|
||||
// (which is stricter than mypy's; see mypy issue #10143 and #10157)
|
||||
// would cause many false positives and catch few bugs.
|
||||
"reportOverlappingOverload": "none",
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
"strictListInference": true,
|
||||
"strictDictionaryInference": true,
|
||||
"strictParameterNoneValue": true,
|
||||
"strictSetInference": true,
|
||||
"reportFunctionMemberAccess": "error",
|
||||
"reportMissingModuleSource": "none",
|
||||
"reportMissingTypeStubs": "error",
|
||||
@@ -110,16 +111,18 @@
|
||||
"reportUnboundVariable": "error",
|
||||
"reportInvalidStubStatement": "error",
|
||||
"reportInvalidTypeVarUse": "error",
|
||||
"reportPropertyTypeMismatch": "none",
|
||||
"reportSelfClsParameterName": "error",
|
||||
"reportUnsupportedDunderAll": "error",
|
||||
// Incompatible overrides are out of typeshed's control as they are
|
||||
// inherited from the implementation.
|
||||
"reportInconsistentConstructor": "error",
|
||||
"reportTypeCommentUsage": "error",
|
||||
"reportUnnecessaryComparison": "error",
|
||||
// Incompatible overrides and property type mismatches are out of typeshed's control
|
||||
// as they are inherited from the implementation.
|
||||
"reportIncompatibleMethodOverride": "none",
|
||||
"reportIncompatibleVariableOverride": "none",
|
||||
// Overlapping overloads cannot be enabled at this time because
|
||||
// of the "fractions.Fraction.__pow__" method and "tasks.gather" function.
|
||||
// Mypy's overlapping overload logic misses these issues (see mypy
|
||||
// issue #10143 and #10157).
|
||||
"reportPropertyTypeMismatch": "none",
|
||||
// Overlapping overloads are often necessary in a stub, meaning pyright's check
|
||||
// (which is stricter than mypy's; see mypy issue #10143 and #10157)
|
||||
// would cause many false positives and catch few bugs.
|
||||
"reportOverlappingOverload": "none",
|
||||
}
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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]): ...
|
||||
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -125,6 +125,15 @@ sqlalchemy.engine.url.URL.normalized_query
|
||||
# runtime has extra internal arguments that are inconsistent across micro versions
|
||||
sqlalchemy.testing.engines.testing_engine
|
||||
|
||||
# __new__ signature conflicts with __init__ signature (which is more precise),
|
||||
# so __new__ is deliberately omitted in the stub
|
||||
sqlalchemy.sql.annotation.Annotated.__new__
|
||||
|
||||
# At runtime __new__ is defined, but we define __init__ in the stub
|
||||
# because otherwise all subclasses would be identified by pyright
|
||||
# as having conflicting __new__/__init__ methods
|
||||
sqlalchemy.orm.unitofwork.PostSortRec.__new__
|
||||
|
||||
# unclear problems
|
||||
sqlalchemy.sql.elements.quoted_name.lower
|
||||
sqlalchemy.sql.elements.quoted_name.upper
|
||||
|
||||
@@ -49,7 +49,10 @@ class Preprocess(IterateMappersMixin):
|
||||
|
||||
class PostSortRec:
|
||||
disabled: Any
|
||||
def __new__(cls, uow, *args): ...
|
||||
# At runtime __new__ is defined, not __init__,
|
||||
# But if we define __new__ here then all subclasses are identified by pyright
|
||||
# as having __init__ methods that are inconsistent with their __new__ methods
|
||||
def __init__(self, uow, *args) -> None: ...
|
||||
def execute_aggregate(self, uow, recs) -> None: ...
|
||||
|
||||
class ProcessAll(IterateMappersMixin, PostSortRec):
|
||||
|
||||
@@ -7,7 +7,6 @@ class SupportsCloneAnnotations(SupportsAnnotations): ...
|
||||
class SupportsWrappingAnnotations(SupportsAnnotations): ...
|
||||
|
||||
class Annotated:
|
||||
def __new__(cls, *args): ...
|
||||
__dict__: Any
|
||||
def __init__(self, element, values) -> None: ...
|
||||
def __reduce__(self): ...
|
||||
|
||||
@@ -5,7 +5,7 @@ import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
_PYRIGHT_VERSION = "1.1.248" # Must match .github/workflows/tests.yml.
|
||||
_PYRIGHT_VERSION = "1.1.254" # Must match .github/workflows/tests.yml.
|
||||
_WELL_KNOWN_FILE = Path("tests", "pyright_test.py")
|
||||
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@ _collections_abc.Set.__rxor__
|
||||
_csv.Dialect.__init__ # C __init__ signature is inaccurate
|
||||
_socket.*
|
||||
_threading_local.local.__new__
|
||||
_weakref.ref.__call__
|
||||
abc.ABCMeta.__new__ # pytype wants the parameter named cls and not mcls
|
||||
_weakref.ref.* # Alias for _weakref.ReferenceType, problems should be fixed there
|
||||
_weakref.CallableProxyType.__getattr__ # Should have all attributes of proxy
|
||||
_weakref.ProxyType.__getattr__ # Should have all attributes of proxy
|
||||
_weakref.ReferenceType.__call__ # C function default annotation is wrong
|
||||
_weakref.ReferenceType.__init__ # Runtime defines __new__ but stubtest thinks __init__ is also defined.
|
||||
argparse.Namespace.__getattr__ # The whole point of this class is its attributes are dynamic
|
||||
asynchat.async_chat.encoding # Removal planned for 3.12, can add if someone needs this
|
||||
asynchat.async_chat.use_encoding # Removal planned for 3.12, can add if someone needs this
|
||||
@@ -221,11 +221,11 @@ urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ # Args are passed as is to
|
||||
warnings.catch_warnings.__init__ # Defining this ruins the __new__ overrides
|
||||
weakref.CallableProxyType.__getattr__ # Should have all attributes of proxy
|
||||
weakref.ProxyType.__getattr__ # Should have all attributes of proxy
|
||||
weakref.ReferenceType.__call__ # C function default annotation is wrong
|
||||
weakref.ReferenceType.* # Alias for _weakref.ReferenceType, problems should be fixed there
|
||||
weakref.WeakKeyDictionary.get
|
||||
weakref.WeakKeyDictionary.update
|
||||
weakref.WeakValueDictionary.get
|
||||
weakref.ref.__call__
|
||||
weakref.ref.* # Alias for _weakref.ReferenceType, problems should be fixed there
|
||||
webbrowser.UnixBrowser.remote_action # always overridden in inheriting class
|
||||
webbrowser.UnixBrowser.remote_action_newtab # always overridden in inheriting class
|
||||
webbrowser.UnixBrowser.remote_action_newwin # always overridden in inheriting class
|
||||
|
||||
Reference in New Issue
Block a user