mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-15 16:27:08 +08:00
add several NamedTuple base classes (#12987)
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user