mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 20:24:30 +08:00
add several NamedTuple base classes (#12987)
This commit is contained in:
@@ -25,10 +25,6 @@ lib2to3.pytree.BasePattern.type
|
||||
lib2to3.pytree.NegatedPattern.match
|
||||
lib2to3.pytree.NegatedPattern.match_seq
|
||||
lib2to3.pgen2.grammar.Grammar.loads
|
||||
# platform.uname_result's processor field is now dynamically made to exist
|
||||
platform.uname_result.__match_args__
|
||||
platform.uname_result.__new__
|
||||
platform.uname_result.processor
|
||||
tkinter.Tk.split
|
||||
tkinter.tix.[A-Z_]+
|
||||
tkinter.tix.TclVersion
|
||||
|
||||
@@ -27,7 +27,6 @@ lib2to3.btm_utils
|
||||
lib2to3.fixer_util
|
||||
lib2to3.patcomp
|
||||
lib2to3.pgen2.grammar.Grammar.loads
|
||||
tkinter._VersionInfoType.__doc__
|
||||
tkinter.tix.[A-Z_]+
|
||||
tkinter.tix.TclVersion
|
||||
tkinter.tix.TkVersion
|
||||
@@ -167,11 +166,6 @@ typing_extensions\.Annotated
|
||||
contextlib.AbstractAsyncContextManager.__class_getitem__
|
||||
contextlib.AbstractContextManager.__class_getitem__
|
||||
|
||||
# platform.uname_result's processor field is now dynamically made to exist
|
||||
platform.uname_result.__match_args__
|
||||
platform.uname_result.__new__
|
||||
platform.uname_result.processor
|
||||
|
||||
# Runtime has *args, **kwargs, but will error if any are supplied
|
||||
unittest.TestCase.__init_subclass__
|
||||
unittest.case.TestCase.__init_subclass__
|
||||
|
||||
@@ -24,7 +24,6 @@ lib2to3.btm_utils
|
||||
lib2to3.fixer_util
|
||||
lib2to3.patcomp
|
||||
lib2to3.pgen2.grammar.Grammar.loads
|
||||
tkinter._VersionInfoType.__doc__
|
||||
tkinter.tix.[A-Z_]+
|
||||
tkinter.tix.TclVersion
|
||||
tkinter.tix.TkVersion
|
||||
@@ -155,11 +154,6 @@ ast.Index.__new__
|
||||
contextlib.AbstractAsyncContextManager.__class_getitem__
|
||||
contextlib.AbstractContextManager.__class_getitem__
|
||||
|
||||
# platform.uname_result's processor field is now dynamically made to exist
|
||||
platform.uname_result.__match_args__
|
||||
platform.uname_result.__new__
|
||||
platform.uname_result.processor
|
||||
|
||||
# Runtime has *args, **kwargs, but will error if any are supplied
|
||||
unittest.TestCase.__init_subclass__
|
||||
unittest.case.TestCase.__init_subclass__
|
||||
|
||||
@@ -42,7 +42,6 @@ _csv.Reader
|
||||
_csv.Writer
|
||||
enum.Enum.__init__
|
||||
importlib._abc.Loader.exec_module # See Lib/importlib/_abc.py. Might be defined for backwards compatibility
|
||||
tkinter._VersionInfoType.__doc__
|
||||
typing.NewType.__mro_entries__
|
||||
builtins.ellipsis # type is not exposed anywhere
|
||||
|
||||
@@ -104,8 +103,6 @@ ast.ImportFrom.level # None on the class, but never None on instances
|
||||
builtins.property.__set_name__ # Doesn't actually exist
|
||||
collections\.UserList\.index # ignoring pos-or-keyword parameter
|
||||
dataclasses.KW_ONLY # white lies around defaults
|
||||
doctest.TestResults.__match_args__ # Stubtest doesn't pick up override
|
||||
doctest.TestResults._fields # Stubtest doesn't pick up override
|
||||
enum.auto.__init__ # The stub for enum.auto is nothing like the implementation
|
||||
enum.auto.value # The stub for enum.auto is nothing like the implementation
|
||||
functools._lru_cache_wrapper.cache_parameters # Cannot be detected statically
|
||||
@@ -131,11 +128,6 @@ ast.Index.__new__
|
||||
contextlib.AbstractAsyncContextManager.__class_getitem__
|
||||
contextlib.AbstractContextManager.__class_getitem__
|
||||
|
||||
# platform.uname_result's processor field is now dynamically made to exist
|
||||
platform.uname_result.__match_args__
|
||||
platform.uname_result.__new__
|
||||
platform.uname_result.processor
|
||||
|
||||
# Runtime has *args, **kwargs, but will error if any are supplied
|
||||
unittest.TestCase.__init_subclass__
|
||||
unittest.case.TestCase.__init_subclass__
|
||||
|
||||
@@ -52,7 +52,6 @@ lib2to3.pytree.BasePattern.type
|
||||
lib2to3.pytree.NegatedPattern.match
|
||||
lib2to3.pytree.NegatedPattern.match_seq
|
||||
lib2to3.pgen2.grammar.Grammar.loads
|
||||
sched.Event.__doc__ # __slots__ is overridden
|
||||
tkinter.tix.[A-Z_]+
|
||||
tkinter.tix.TclVersion
|
||||
tkinter.tix.TkVersion
|
||||
|
||||
@@ -39,11 +39,6 @@ lib2to3.pytree.BasePattern.type
|
||||
lib2to3.pytree.NegatedPattern.match
|
||||
lib2to3.pytree.NegatedPattern.match_seq
|
||||
lib2to3.pgen2.grammar.Grammar.loads
|
||||
# platform.uname_result's processor field is now dynamically made to exist
|
||||
platform.uname_result.__new__
|
||||
platform.uname_result._fields
|
||||
platform.uname_result.processor
|
||||
sched.Event.__doc__ # __slots__ is overridden
|
||||
tkinter.Tk.split
|
||||
tkinter.tix.[A-Z_]+
|
||||
tkinter.tix.TclVersion
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
import sys
|
||||
from typing import Final
|
||||
from typing import Final, NamedTuple, type_check_only
|
||||
|
||||
if sys.platform != "win32":
|
||||
class _Method: ...
|
||||
@type_check_only
|
||||
class _MethodBase(NamedTuple):
|
||||
name: str
|
||||
ident: str | None
|
||||
salt_chars: int
|
||||
total_size: int
|
||||
|
||||
class _Method(_MethodBase): ...
|
||||
METHOD_CRYPT: Final[_Method]
|
||||
METHOD_MD5: Final[_Method]
|
||||
METHOD_SHA256: Final[_Method]
|
||||
|
||||
@@ -3,7 +3,7 @@ import types
|
||||
import unittest
|
||||
from _typeshed import ExcInfo
|
||||
from collections.abc import Callable
|
||||
from typing import Any, ClassVar, NamedTuple
|
||||
from typing import Any, NamedTuple, type_check_only
|
||||
from typing_extensions import Self, TypeAlias
|
||||
|
||||
__all__ = [
|
||||
@@ -42,17 +42,15 @@ __all__ = [
|
||||
"debug",
|
||||
]
|
||||
|
||||
# MyPy errors on conditionals within named tuples.
|
||||
|
||||
if sys.version_info >= (3, 13):
|
||||
class TestResults(NamedTuple):
|
||||
def __new__(cls, failed: int, attempted: int, *, skipped: int = 0) -> Self: ... # type: ignore[misc]
|
||||
skipped: int
|
||||
@type_check_only
|
||||
class _TestResultsBase(NamedTuple):
|
||||
failed: int
|
||||
attempted: int
|
||||
_fields: ClassVar = ("failed", "attempted") # type: ignore[misc]
|
||||
__match_args__ = ("failed", "attempted") # type: ignore[misc]
|
||||
__doc__: None # type: ignore[misc]
|
||||
|
||||
class TestResults(_TestResultsBase):
|
||||
def __new__(cls, failed: int, attempted: int, *, skipped: int = 0) -> Self: ...
|
||||
skipped: int
|
||||
|
||||
else:
|
||||
class TestResults(NamedTuple):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import sys
|
||||
from typing import NamedTuple
|
||||
from typing import NamedTuple, type_check_only
|
||||
|
||||
def libc_ver(executable: str | None = None, lib: str = "", version: str = "", chunksize: int = 16384) -> tuple[str, str]: ...
|
||||
def win32_ver(release: str = "", version: str = "", csd: str = "", ptype: str = "") -> tuple[str, str, str, str]: ...
|
||||
@@ -14,13 +14,27 @@ def java_ver(
|
||||
def system_alias(system: str, release: str, version: str) -> tuple[str, str, str]: ...
|
||||
def architecture(executable: str = sys.executable, bits: str = "", linkage: str = "") -> tuple[str, str]: ...
|
||||
|
||||
class uname_result(NamedTuple):
|
||||
system: str
|
||||
node: str
|
||||
release: str
|
||||
version: str
|
||||
machine: str
|
||||
processor: str
|
||||
if sys.version_info >= (3, 9):
|
||||
@type_check_only
|
||||
class _uname_result_base(NamedTuple):
|
||||
system: str
|
||||
node: str
|
||||
release: str
|
||||
version: str
|
||||
machine: str
|
||||
|
||||
class uname_result(_uname_result_base):
|
||||
@property
|
||||
def processor(self) -> str: ...
|
||||
|
||||
else:
|
||||
class uname_result(NamedTuple):
|
||||
system: str
|
||||
node: str
|
||||
release: str
|
||||
version: str
|
||||
machine: str
|
||||
processor: str
|
||||
|
||||
def uname() -> uname_result: ...
|
||||
def system() -> str: ...
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import sys
|
||||
from collections.abc import Callable
|
||||
from typing import Any, NamedTuple
|
||||
from typing import Any, NamedTuple, type_check_only
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__all__ = ["scheduler"]
|
||||
@@ -17,13 +17,16 @@ if sys.version_info >= (3, 10):
|
||||
kwargs: dict[str, Any]
|
||||
|
||||
else:
|
||||
class Event(NamedTuple):
|
||||
@type_check_only
|
||||
class _EventBase(NamedTuple):
|
||||
time: float
|
||||
priority: Any
|
||||
action: _ActionCallback
|
||||
argument: tuple[Any, ...]
|
||||
kwargs: dict[str, Any]
|
||||
|
||||
class Event(_EventBase): ...
|
||||
|
||||
class scheduler:
|
||||
timefunc: Callable[[], float]
|
||||
delayfunc: Callable[[float], object]
|
||||
|
||||
@@ -186,13 +186,16 @@ _XYScrollCommand: TypeAlias = str | Callable[[float, float], object]
|
||||
_TakeFocusValue: TypeAlias = bool | Literal[0, 1, ""] | Callable[[str], bool | None] # -takefocus in manual page named 'options'
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
class _VersionInfoType(NamedTuple):
|
||||
@type_check_only
|
||||
class _VersionInfoTypeBase(NamedTuple):
|
||||
major: int
|
||||
minor: int
|
||||
micro: int
|
||||
releaselevel: str
|
||||
serial: int
|
||||
|
||||
class _VersionInfoType(_VersionInfoTypeBase): ...
|
||||
|
||||
class EventType(StrEnum):
|
||||
Activate = "36"
|
||||
ButtonPress = "4"
|
||||
|
||||
Reference in New Issue
Block a user