Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion stubs/RPi.GPIO/RPi/GPIO/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from collections.abc import Callable
from typing import Final, Literal, TypedDict
from typing import Final, Literal, TypedDict, type_check_only
from typing_extensions import TypeAlias

@type_check_only
class _RPi_Info(TypedDict):
P1_REVISION: int
REVISION: str
Expand Down
4 changes: 3 additions & 1 deletion stubs/WebOb/webob/_types.pyi
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
from typing import Protocol, TypeVar, overload
from typing import Protocol, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias

_T = TypeVar("_T")
_GetterReturnType_co = TypeVar("_GetterReturnType_co", covariant=True)
_SetterValueType_contra = TypeVar("_SetterValueType_contra", contravariant=True)

@type_check_only
class AsymmetricProperty(Protocol[_GetterReturnType_co, _SetterValueType_contra]):
@overload
def __get__(self, obj: None, type: type[object] | None = ..., /) -> property: ...
@overload
def __get__(self, obj: object, type: type[object] | None = ..., /) -> _GetterReturnType_co: ...
def __set__(self, obj: object, value: _SetterValueType_contra, /) -> None: ...

@type_check_only
class AsymmetricPropertyWithDelete(
AsymmetricProperty[_GetterReturnType_co, _SetterValueType_contra], Protocol[_GetterReturnType_co, _SetterValueType_contra]
):
Expand Down
3 changes: 2 additions & 1 deletion stubs/docker/docker/types/services.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from _typeshed import Incomplete
from collections.abc import Iterable, Mapping
from typing import Final, Literal, TypedDict, TypeVar, overload
from typing import Final, Literal, TypedDict, TypeVar, overload, type_check_only

from .healthcheck import Healthcheck

Expand Down Expand Up @@ -75,6 +75,7 @@ class Mount(dict[str, Incomplete]):
@classmethod
def parse_mount_string(cls, string: str) -> Mount: ...

@type_check_only
class _ResourceDict(TypedDict):
Kind: str
Value: int
Expand Down
3 changes: 2 additions & 1 deletion stubs/docutils/docutils/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from typing import Any, ClassVar, Final, NamedTuple
from typing import Any, ClassVar, Final, NamedTuple, type_check_only
from typing_extensions import Self

from docutils.transforms import Transform

__docformat__: Final = "reStructuredText"
__version__: Final[str]

@type_check_only
class _VersionInfo(NamedTuple):
major: int
minor: int
Expand Down
3 changes: 2 additions & 1 deletion stubs/fpdf2/fpdf/_fonttools_shims.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
from abc import ABCMeta, abstractmethod
from collections.abc import Mapping
from logging import Logger
from typing import Any, Protocol
from typing import Any, Protocol, type_check_only
from typing_extensions import TypeAlias

# from fonttools.ttLib.ttGlyphSet
@type_check_only
class _TTGlyph(Protocol):
def __init__(self, glyphSet: _TTGlyphSet, glyphName: str) -> None: ...
def draw(self, pen) -> None: ...
Expand Down
4 changes: 3 additions & 1 deletion stubs/fpdf2/fpdf/drawing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class GraphicsStateDictRegistry(OrderedDict[Raw, Name]):

def number_to_str(number: Number) -> str: ...
def render_pdf_primitive(primitive: _Primitive) -> Raw: ...

@type_check_only
class _DeviceRGBBase(NamedTuple):
r: Number
g: Number
Expand All @@ -75,6 +75,7 @@ class DeviceRGB(_DeviceRGBBase):
def colors255(self) -> tuple[Number, Number, Number]: ...
def serialize(self) -> str: ...

@type_check_only
class _DeviceGrayBase(NamedTuple):
g: Number
a: Number | None
Expand All @@ -88,6 +89,7 @@ class DeviceGray(_DeviceGrayBase):
def colors255(self) -> tuple[Number, Number, Number]: ...
def serialize(self) -> str: ...

@type_check_only
class _DeviceCMYKBase(NamedTuple):
c: Number
m: Number
Expand Down
12 changes: 11 additions & 1 deletion stubs/gevent/gevent/_types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sys
from _typeshed import FileDescriptor, StrOrBytesPath
from collections.abc import Callable
from types import TracebackType
from typing import Any, Literal, Protocol, overload
from typing import Any, Literal, Protocol, overload, type_check_only
from typing_extensions import TypeAlias, TypeVarTuple, Unpack

_Ts = TypeVarTuple("_Ts")
Expand All @@ -19,6 +19,7 @@ _Ts = TypeVarTuple("_Ts")
# properties and methods that are available on all event loops, so these have
# been added as well, instead of completely mirroring the internal interface

@type_check_only
class _Loop(Protocol): # noqa: Y046
@property
def approx_timer_resolution(self) -> float: ...
Expand Down Expand Up @@ -66,13 +67,15 @@ class _Loop(Protocol): # noqa: Y046
def run_callback_threadsafe(self, func: Callable[[Unpack[_Ts]], Any], *args: Unpack[_Ts]) -> _Callback: ...
def fileno(self) -> FileDescriptor | None: ...

@type_check_only
class _Watcher(Protocol):
# while IWatcher allows for kwargs the actual implementation does not...
def start(self, callback: Callable[[Unpack[_Ts]], Any], *args: Unpack[_Ts]) -> None: ...
def stop(self) -> None: ...
def close(self) -> None: ...

# this matches Intersection[_Watcher, TimerMixin]
@type_check_only
class _TimerWatcher(_Watcher, Protocol):
# this has one specific allowed keyword argument, if it is given we don't try to check
# the passed in arguments, but if it isn't passed in, then we do.
Expand All @@ -86,6 +89,7 @@ class _TimerWatcher(_Watcher, Protocol):
def again(self, callback: Callable[[Unpack[_Ts]], Any], *args: Unpack[_Ts]) -> None: ...

# this matches Intersection[_Watcher, IoMixin]
@type_check_only
class _IoWatcher(_Watcher, Protocol):
EVENT_MASK: int
# pass_events means the first argument of the callback needs to be an integer, but we can't
Expand All @@ -96,6 +100,7 @@ class _IoWatcher(_Watcher, Protocol):
def start(self, callback: Callable[[Unpack[_Ts]], Any], *args: Unpack[_Ts]) -> None: ...

# this matches Intersection[_Watcher, ChildMixin]
@type_check_only
class _ChildWatcher(_Watcher, Protocol):
@property
def pid(self) -> int: ...
Expand All @@ -105,18 +110,21 @@ class _ChildWatcher(_Watcher, Protocol):
def rstatus(self) -> int: ...

# this matches Intersection[_Watcher, AsyncMixin]
@type_check_only
class _AsyncWatcher(_Watcher, Protocol):
def send(self) -> None: ...
def send_ignoring_arg(self, ignored: object, /) -> None: ...
@property
def pending(self) -> bool: ...

# all implementations return something of this shape
@type_check_only
class _StatResult(Protocol):
@property
def st_nlink(self) -> int: ...

# this matches Intersection[_Watcher, StatMixin]
@type_check_only
class _StatWatcher(_Watcher, Protocol):
@property
def path(self) -> StrOrBytesPath: ...
Expand All @@ -127,6 +135,7 @@ class _StatWatcher(_Watcher, Protocol):
@property
def interval(self) -> float: ...

@type_check_only
class _Callback(Protocol):
pending: bool
def stop(self) -> None: ...
Expand All @@ -137,6 +146,7 @@ _SockAddr: TypeAlias = _FullSockAddr | tuple[str, int]
_AddrinfoResult: TypeAlias = list[tuple[int, int, int, str, _SockAddr]] # family, type, protocol, cname, sockaddr
_NameinfoResult: TypeAlias = tuple[str, str]

@type_check_only
class _Resolver(Protocol): # noqa: Y046
def close(self) -> None: ...
def gethostbyname(self, hostname: str, family: int = 2) -> str: ...
Expand Down
20 changes: 19 additions & 1 deletion stubs/openpyxl/openpyxl/xml/_functions_overloads.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from _typeshed import Incomplete, ReadableBuffer
from collections.abc import Iterable, Iterator, Mapping, Sequence
from typing import Any, Protocol, TypeVar, overload
from typing import Any, Protocol, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
from xml.etree.ElementTree import Element, ElementTree, QName, XMLParser, _FileRead

Expand All @@ -17,34 +17,52 @@ _T_co = TypeVar("_T_co", covariant=True)
# Usually an Element() from either lxml or xml.etree (has a 'tag' element)
# lxml.etree._Element
# xml.etree.Element
@type_check_only
class _HasTag(Protocol):
tag: str

@type_check_only
class _HasGet(Protocol[_T_co]):
def get(self, value: str, /) -> _T_co | None: ...

@type_check_only
class _HasText(Protocol):
text: str

@type_check_only
class _HasAttrib(Protocol):
attrib: Iterable[Any] # AnyOf[dict[str, str], Iterable[tuple[str, str]]]

@type_check_only
class _HasTagAndGet(_HasTag, _HasGet[_T_co], Protocol[_T_co]): ... # noqa: Y046

@type_check_only
class _HasTagAndText(_HasTag, _HasText, Protocol): ... # noqa: Y046

@type_check_only
class _HasTagAndTextAndAttrib(_HasTag, _HasText, _HasAttrib, Protocol): ... # noqa: Y046

@type_check_only
class _SupportsFindChartLines(Protocol):
def find(self, path: str, /) -> ChartLines | None: ...

@type_check_only
class _SupportsFindAndIterAndAttribAndText( # noqa: Y046
_SupportsFindChartLines, Iterable[Incomplete], _HasAttrib, _HasText, Protocol
): ...

@type_check_only
class _SupportsIterAndAttrib(Iterable[Incomplete], _HasAttrib, Protocol): ... # noqa: Y046

@type_check_only
class _SupportsIterAndAttribAndTextAndTag(Iterable[Incomplete], _HasAttrib, _HasText, _HasTag, Protocol): ... # noqa: Y046

@type_check_only
class _SupportsIterAndAttribAndTextAndGet( # noqa: Y046
Iterable[Incomplete], _HasAttrib, _HasText, _HasGet[Incomplete], Protocol
): ...

@type_check_only
class _ParentElement(Protocol[_T]):
def makeelement(self, tag: str, attrib: dict[str, str], /) -> _T: ...
def append(self, element: _T, /) -> object: ...
Expand Down
1 change: 0 additions & 1 deletion stubs/paramiko/@tests/stubtest_allowlist.txt

This file was deleted.

5 changes: 1 addition & 4 deletions stubs/paramiko/paramiko/util.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ from collections.abc import Iterable
from hashlib import _Hash
from logging import Logger, LogRecord
from types import TracebackType
from typing import IO, AnyStr, Protocol
from typing import IO, AnyStr
from typing_extensions import Self

from paramiko.config import SSHConfig, SSHConfigDict
from paramiko.hostkeys import HostKeys

class SupportsClose(Protocol):
def close(self) -> None: ...

def inflate_long(s: bytes | bytearray, always_positive: bool = False) -> int: ...
def deflate_long(n: int, add_sign_padding: bool = True) -> bytes: ...
def format_binary(data: bytes | bytearray, prefix: str = "") -> list[str]: ...
Expand Down
3 changes: 2 additions & 1 deletion stubs/pony/pony/flask/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from _typeshed import Incomplete
from types import ModuleType
from typing import Protocol
from typing import Protocol, type_check_only

# Protocol for flask.Flask class
@type_check_only
class _Flask(Protocol):
def before_request(self, f): ...
def after_request(self, f): ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
# Anything not referenced in the PyInstaller stubs doesn't need to be added here.

from types import CodeType
from typing import Protocol
from typing import Protocol, type_check_only

@type_check_only
class _SupportsGraphident(Protocol):
graphident: str

Expand Down
3 changes: 2 additions & 1 deletion stubs/qrcode/qrcode/_types.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Type aliases used in this stub package
from _typeshed import SupportsWrite
from typing import Any, Protocol
from typing import Any, Protocol, type_check_only
from typing_extensions import TypeAlias

Box: TypeAlias = tuple[tuple[int, int], tuple[int, int]]
Expand All @@ -11,5 +11,6 @@ Ink: TypeAlias = tuple[int, int, int] | tuple[int, int, int, int]
ErrorCorrect: TypeAlias = int
MaskPattern: TypeAlias = int

@type_check_only
class Writeable(SupportsWrite[bytes], Protocol):
def seek(self, offset: int, /) -> Any: ...
4 changes: 3 additions & 1 deletion stubs/tensorflow/tensorflow/_aliases.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Everything in this module is private for stubs. There is no runtime equivalent.

from collections.abc import Iterable, Mapping, Sequence
from typing import Any, Protocol, TypeVar
from typing import Any, Protocol, TypeVar, type_check_only
from typing_extensions import TypeAlias

import numpy as np
Expand All @@ -20,9 +20,11 @@ RaggedTensorLike: TypeAlias = tf.Tensor | tf.RaggedTensor
# _RaggedTensorLikeT = TypeVar("_RaggedTensorLikeT", tf.Tensor, tf.RaggedTensor)
Gradients: TypeAlias = tf.Tensor | tf.IndexedSlices

@type_check_only
class KerasSerializable1(Protocol):
def get_config(self) -> dict[str, Any]: ...

@type_check_only
class KerasSerializable2(Protocol):
__name__: str

Expand Down
3 changes: 2 additions & 1 deletion stubs/tensorflow/tensorflow/config/experimental.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import typing_extensions
from typing import TypedDict
from typing import TypedDict, type_check_only

from tensorflow.config import PhysicalDevice

@type_check_only
class _MemoryInfo(TypedDict):
current: int
peak: int
Expand Down
Loading