Fix doctest for 3.13 (#12625)

This commit is contained in:
Max Muoto
2024-09-08 05:38:13 -05:00
committed by GitHub
parent 61ed105cdb
commit 089953ed84
2 changed files with 23 additions and 7 deletions

View File

@@ -4,8 +4,6 @@
# TODO: triage these new errors
_tkinter.create
doctest.TestResults.__doc__
doctest.TestResults.__new__
importlib.resources.Anchor
importlib.resources.Resource
importlib.resources.__all__
@@ -119,6 +117,8 @@ 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

View File

@@ -1,9 +1,10 @@
import sys
import types
import unittest
from _typeshed import ExcInfo
from collections.abc import Callable
from typing import Any, NamedTuple
from typing_extensions import TypeAlias
from typing import Any, ClassVar, NamedTuple
from typing_extensions import Self, TypeAlias
__all__ = [
"register_optionflag",
@@ -41,9 +42,22 @@ __all__ = [
"debug",
]
class TestResults(NamedTuple):
failed: int
attempted: int
# 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
failed: int
attempted: int
_fields: ClassVar = ("failed", "attempted") # type: ignore[misc]
__match_args__ = ("failed", "attempted") # type: ignore[misc]
__doc__: None # type: ignore[misc]
else:
class TestResults(NamedTuple):
failed: int
attempted: int
OPTIONFLAGS_BY_NAME: dict[str, int]
@@ -134,6 +148,8 @@ class DocTestRunner:
original_optionflags: int
tries: int
failures: int
if sys.version_info >= (3, 13):
skips: int
test: DocTest
def __init__(self, checker: OutputChecker | None = None, verbose: bool | None = None, optionflags: int = 0) -> None: ...
def report_start(self, out: _Out, test: DocTest, example: Example) -> None: ...