mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-06-26 02:34:03 +08:00
Add @type_check_only to stub-only private classes in stdlib (#14512)
This commit is contained in:
@@ -366,12 +366,14 @@ def getboolean(s): ...
|
||||
|
||||
_Ts = TypeVarTuple("_Ts")
|
||||
|
||||
@type_check_only
|
||||
class _GridIndexInfo(TypedDict, total=False):
|
||||
minsize: _ScreenUnits
|
||||
pad: _ScreenUnits
|
||||
uniform: str | None
|
||||
weight: int
|
||||
|
||||
@type_check_only
|
||||
class _BusyInfo(TypedDict):
|
||||
cursor: _Cursor
|
||||
|
||||
@@ -1039,6 +1041,7 @@ def Tcl(screenName: str | None = None, baseName: str | None = None, className: s
|
||||
_InMiscTotal = TypedDict("_InMiscTotal", {"in": Misc})
|
||||
_InMiscNonTotal = TypedDict("_InMiscNonTotal", {"in": Misc}, total=False)
|
||||
|
||||
@type_check_only
|
||||
class _PackInfo(_InMiscTotal):
|
||||
# 'before' and 'after' never appear in _PackInfo
|
||||
anchor: _Anchor
|
||||
@@ -1080,6 +1083,7 @@ class Pack:
|
||||
forget = pack_forget
|
||||
propagate = Misc.pack_propagate
|
||||
|
||||
@type_check_only
|
||||
class _PlaceInfo(_InMiscNonTotal): # empty dict if widget hasn't been placed
|
||||
anchor: _Anchor
|
||||
bordermode: Literal["inside", "outside", "ignore"]
|
||||
@@ -1116,6 +1120,7 @@ class Place:
|
||||
place = place_configure
|
||||
info = place_info
|
||||
|
||||
@type_check_only
|
||||
class _GridInfo(_InMiscNonTotal): # empty dict if widget hasn't been gridded
|
||||
column: int
|
||||
columnspan: int
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from tkinter import Event, Misc, Tk, Widget
|
||||
from typing import ClassVar, Protocol
|
||||
from typing import ClassVar, Protocol, type_check_only
|
||||
|
||||
__all__ = ["dnd_start", "DndHandler"]
|
||||
|
||||
@type_check_only
|
||||
class _DndSource(Protocol):
|
||||
def dnd_end(self, target: Widget | None, event: Event[Misc] | None, /) -> None: ...
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import _tkinter
|
||||
import itertools
|
||||
import sys
|
||||
import tkinter
|
||||
from typing import Any, ClassVar, Final, Literal, TypedDict, overload
|
||||
from typing import Any, ClassVar, Final, Literal, TypedDict, overload, type_check_only
|
||||
from typing_extensions import TypeAlias, Unpack
|
||||
|
||||
__all__ = ["NORMAL", "ROMAN", "BOLD", "ITALIC", "nametofont", "Font", "families", "names"]
|
||||
@@ -23,6 +23,7 @@ _FontDescription: TypeAlias = (
|
||||
| _tkinter.Tcl_Obj # A font object constructed in Tcl
|
||||
)
|
||||
|
||||
@type_check_only
|
||||
class _FontDict(TypedDict):
|
||||
family: str
|
||||
size: int
|
||||
@@ -31,6 +32,7 @@ class _FontDict(TypedDict):
|
||||
underline: bool
|
||||
overstrike: bool
|
||||
|
||||
@type_check_only
|
||||
class _MetricsDict(TypedDict):
|
||||
ascent: int
|
||||
descent: int
|
||||
|
||||
@@ -3,7 +3,7 @@ import tkinter
|
||||
from _typeshed import Incomplete, MaybeNone
|
||||
from collections.abc import Callable
|
||||
from tkinter.font import _FontDescription
|
||||
from typing import Any, Literal, TypedDict, overload
|
||||
from typing import Any, Literal, TypedDict, overload, type_check_only
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__all__ = [
|
||||
@@ -928,6 +928,7 @@ class Spinbox(Entry):
|
||||
config = configure # type: ignore[assignment]
|
||||
def set(self, value: Any) -> None: ...
|
||||
|
||||
@type_check_only
|
||||
class _TreeviewItemDict(TypedDict):
|
||||
text: str
|
||||
image: list[str] | Literal[""] # no idea why it's wrapped in list
|
||||
@@ -935,6 +936,7 @@ class _TreeviewItemDict(TypedDict):
|
||||
open: bool # actually 0 or 1
|
||||
tags: list[str] | Literal[""]
|
||||
|
||||
@type_check_only
|
||||
class _TreeviewTagDict(TypedDict):
|
||||
# There is also 'text' and 'anchor', but they don't seem to do anything, using them is likely a bug
|
||||
foreground: str
|
||||
@@ -942,6 +944,7 @@ class _TreeviewTagDict(TypedDict):
|
||||
font: _FontDescription
|
||||
image: str # not wrapped in list :D
|
||||
|
||||
@type_check_only
|
||||
class _TreeviewHeaderDict(TypedDict):
|
||||
text: str
|
||||
image: list[str] | Literal[""]
|
||||
@@ -949,6 +952,7 @@ class _TreeviewHeaderDict(TypedDict):
|
||||
command: str
|
||||
state: str # Doesn't seem to appear anywhere else than in these dicts
|
||||
|
||||
@type_check_only
|
||||
class _TreeviewColumnDict(TypedDict):
|
||||
width: int
|
||||
minwidth: int
|
||||
|
||||
Reference in New Issue
Block a user