mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
Fix miscellaneous invalid TypeVar usages (#8074)
This commit is contained in:
@@ -164,7 +164,7 @@ def POINTER(type: type[_CT]) -> type[pointer[_CT]]: ...
|
||||
class pointer(Generic[_CT], _PointerLike, _CData):
|
||||
_type_: type[_CT]
|
||||
contents: _CT
|
||||
def __init__(self, arg: _CT = ...) -> None: ...
|
||||
def __init__(self, arg: _CT) -> None: ...
|
||||
@overload
|
||||
def __getitem__(self, __i: int) -> _CT: ...
|
||||
@overload
|
||||
|
||||
@@ -28,8 +28,17 @@ class Match(NamedTuple):
|
||||
size: int
|
||||
|
||||
class SequenceMatcher(Generic[_T]):
|
||||
@overload
|
||||
def __init__(self, isjunk: Callable[[_T], bool] | None, a: Sequence[_T], b: Sequence[_T], autojunk: bool = ...) -> None: ...
|
||||
@overload
|
||||
def __init__(self, *, a: Sequence[_T], b: Sequence[_T], autojunk: bool = ...) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self, isjunk: Callable[[_T], bool] | None = ..., a: Sequence[_T] = ..., b: Sequence[_T] = ..., autojunk: bool = ...
|
||||
self: SequenceMatcher[str],
|
||||
isjunk: Callable[[str], bool] | None = ...,
|
||||
a: Sequence[str] = ...,
|
||||
b: Sequence[str] = ...,
|
||||
autojunk: bool = ...,
|
||||
) -> None: ...
|
||||
def set_seqs(self, a: Sequence[_T], b: Sequence[_T]) -> None: ...
|
||||
def set_seq1(self, a: Sequence[_T]) -> None: ...
|
||||
|
||||
@@ -46,9 +46,10 @@ class Mailbox(Generic[_MessageT]):
|
||||
|
||||
_path: bytes | str # undocumented
|
||||
_factory: Callable[[IO[Any]], _MessageT] | None # undocumented
|
||||
def __init__(
|
||||
self, path: StrOrBytesPath, factory: Callable[[IO[Any]], _MessageT] | None = ..., create: bool = ...
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(self, path: StrOrBytesPath, factory: Callable[[IO[Any]], _MessageT], create: bool = ...) -> None: ...
|
||||
@overload
|
||||
def __init__(self, path: StrOrBytesPath, factory: None = ..., create: bool = ...) -> None: ...
|
||||
@abstractmethod
|
||||
def add(self, message: _MessageData) -> str: ...
|
||||
@abstractmethod
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import sys
|
||||
from _typeshed import Self
|
||||
from collections.abc import Iterable
|
||||
from typing import Any, Generic, TypeVar
|
||||
from typing import Any, Generic, TypeVar, overload
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
@@ -23,7 +23,10 @@ class SharedMemory:
|
||||
|
||||
class ShareableList(Generic[_SLT]):
|
||||
shm: SharedMemory
|
||||
def __init__(self, sequence: Iterable[_SLT] | None = ..., *, name: str | None = ...) -> None: ...
|
||||
@overload
|
||||
def __init__(self, sequence: None = ..., *, name: str | None = ...) -> None: ...
|
||||
@overload
|
||||
def __init__(self, sequence: Iterable[_SLT], *, name: str | None = ...) -> None: ...
|
||||
def __getitem__(self, position: int) -> _SLT: ...
|
||||
def __setitem__(self, position: int, value: _SLT) -> None: ...
|
||||
def __reduce__(self: Self) -> tuple[Self, tuple[_SLT, ...]]: ...
|
||||
|
||||
@@ -355,25 +355,27 @@ class TemporaryDirectory(Generic[AnyStr]):
|
||||
@overload
|
||||
def __init__(
|
||||
self: TemporaryDirectory[str],
|
||||
suffix: None = ...,
|
||||
prefix: None = ...,
|
||||
dir: None = ...,
|
||||
suffix: str | None = ...,
|
||||
prefix: str | None = ...,
|
||||
dir: StrPath | None = ...,
|
||||
ignore_cleanup_errors: bool = ...,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self,
|
||||
suffix: AnyStr | None = ...,
|
||||
prefix: AnyStr | None = ...,
|
||||
dir: GenericPath[AnyStr] | None = ...,
|
||||
self: TemporaryDirectory[bytes],
|
||||
suffix: bytes | None = ...,
|
||||
prefix: bytes | None = ...,
|
||||
dir: BytesPath | None = ...,
|
||||
ignore_cleanup_errors: bool = ...,
|
||||
) -> None: ...
|
||||
else:
|
||||
@overload
|
||||
def __init__(self: TemporaryDirectory[str], suffix: None = ..., prefix: None = ..., dir: None = ...) -> None: ...
|
||||
def __init__(
|
||||
self: TemporaryDirectory[str], suffix: str | None = ..., prefix: str | None = ..., dir: StrPath | None = ...
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self, suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., dir: GenericPath[AnyStr] | None = ...
|
||||
self: TemporaryDirectory[bytes], suffix: bytes | None = ..., prefix: bytes | None = ..., dir: BytesPath | None = ...
|
||||
) -> None: ...
|
||||
|
||||
def cleanup(self) -> None: ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import argparse
|
||||
import ast
|
||||
from collections.abc import Iterable, Iterator
|
||||
from typing import Any, Generic, TypeVar
|
||||
from typing import Any, Generic, TypeVar, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
FLAKE8_ERROR: TypeAlias = tuple[int, int, str, type[Any]]
|
||||
@@ -18,7 +18,10 @@ class Error:
|
||||
|
||||
class Visitor(ast.NodeVisitor, Generic[TConfig]):
|
||||
errors: list[Error]
|
||||
def __init__(self, config: TConfig | None = ...) -> None: ...
|
||||
@overload
|
||||
def __init__(self, config: None = ...) -> None: ...
|
||||
@overload
|
||||
def __init__(self, config: TConfig) -> None: ...
|
||||
@property
|
||||
def config(self) -> TConfig: ...
|
||||
def error_from_node(self, error: type[Error], node: ast.AST, **kwargs: Any) -> None: ...
|
||||
|
||||
@@ -88,7 +88,6 @@ ctypes.memset # CFunctionType
|
||||
ctypes.pointer # imported C function
|
||||
ctypes.string_at # docstring argument name is wrong
|
||||
ctypes.wstring_at # docstring argument name is wrong
|
||||
difflib.SequenceMatcher.__init__ # mypy default value for generic parameter issues. See https://github.com/python/mypy/issues/3737
|
||||
distutils.command.bdist_packager # It exists in docs as package name but not in code except as a mention in a comment.
|
||||
distutils.version.Version._cmp # class should have declared this
|
||||
distutils.version.Version.parse # class should have declared this
|
||||
|
||||
Reference in New Issue
Block a user