Use ConvertibleToInt/ConvertibleToFloat in many third-party stubs (#11022)

Note: this may make the latest version of certain stubs packages incompatible with older versions of mypy and pyright.
This commit is contained in:
Avasam
2023-11-29 06:23:00 -05:00
committed by GitHub
parent 09668963a1
commit 4687faab8e
80 changed files with 831 additions and 970 deletions

View File

@@ -1,7 +1,7 @@
from _typeshed import ReadableBuffer, SliceableBuffer
from _typeshed import ConvertibleToFloat, SliceableBuffer
from collections.abc import Iterable, Sequence
from typing import SupportsFloat, TypeVar
from typing_extensions import Final, SupportsIndex, TypeAlias
from typing import TypeVar
from typing_extensions import Final
from Xlib._typing import Unused
from Xlib.display import Display
@@ -9,7 +9,6 @@ from Xlib.protocol import display, request, rq
from Xlib.xobject import drawable, resource
_T = TypeVar("_T")
_Floatable: TypeAlias = SupportsFloat | SupportsIndex | str | ReadableBuffer
extname: Final = "XInputExtension"
PropertyDeleted: Final = 0
@@ -119,12 +118,12 @@ PROPERTY_TYPE_FLOAT: Final = "FLOAT"
# ignore[override] because of Liskov substitution principle violations
class FP1616(rq.Int32):
def check_value(self, value: float) -> int: ... # type: ignore[override]
def parse_value(self, value: _Floatable, display: Unused) -> float: ... # type: ignore[override]
def parse_value(self, value: ConvertibleToFloat, display: Unused) -> float: ... # type: ignore[override]
class FP3232(rq.ValueField):
structcode: str
def check_value(self, value: _T) -> _T: ... # type: ignore[override]
def parse_value(self, value: tuple[_Floatable, _Floatable], display: Unused) -> float: ... # type: ignore[override]
def parse_value(self, value: tuple[ConvertibleToFloat, ConvertibleToFloat], display: Unused) -> float: ... # type: ignore[override]
class XIQueryVersion(rq.ReplyRequest): ...

View File

@@ -1,10 +1,10 @@
from _typeshed import ReadableBuffer, SliceableBuffer, SupportsTrunc
from _typeshed import ConvertibleToInt, SliceableBuffer
from array import array
# Avoid name collision with List.type
from builtins import type as Type
from collections.abc import Callable, Iterable, Sequence
from typing import Any, SupportsInt, TypeVar, overload, type_check_only
from typing import Any, TypeVar, overload, type_check_only
from typing_extensions import Final, Literal, LiteralString, SupportsIndex, TypeAlias
from Xlib._typing import ErrorHandler, Unused
@@ -14,7 +14,6 @@ from Xlib.ext.xinput import ClassInfoClass
from Xlib.protocol import display
_T = TypeVar("_T")
_IntNew: TypeAlias = str | ReadableBuffer | SupportsInt | SupportsIndex | SupportsTrunc
_ModifierMappingList8Elements: TypeAlias = Sequence[Sequence[int]]
def decode_string(bs: bytes | bytearray) -> str: ...
@@ -237,7 +236,7 @@ class Object(ValueField):
class PropertyData(ValueField):
structcode: None
def parse_binary_value(
self, data: SliceableBuffer, display: Unused, length: _IntNew | None, format: int
self, data: SliceableBuffer, display: Unused, length: ConvertibleToInt | None, format: int
) -> tuple[tuple[int, SliceableBuffer] | None, SliceableBuffer]: ...
def pack_value( # type: ignore[override] # Override Callable
self, value: tuple[int, Sequence[float] | Sequence[str]]