Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ConvertibleToInt and ConvertibleToFloat in 3rd-party stubs #35

Closed
wants to merge 1 commit into from
Closed
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
40 changes: 22 additions & 18 deletions stubs/PyAutoGUI/pyautogui/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import contextlib
from _typeshed import ConvertibleToInt
from collections.abc import Callable, Iterable, Sequence
from datetime import datetime
from typing import NamedTuple, SupportsInt, TypeVar
from typing import NamedTuple, TypeVar
from typing_extensions import Final, ParamSpec, SupportsIndex, TypeAlias

from pyscreeze import (
Expand All @@ -19,7 +20,10 @@ from pyscreeze import (

_P = ParamSpec("_P")
_R = TypeVar("_R")
_NormalizeableXArg: TypeAlias = str | SupportsInt | Sequence[SupportsInt]
# Explicitely mentionning str despite being in the ConvertibleToInt Alias because it has a different meaning (filename on screen)
# Specifying non-None Y arg when X is a string or sequence raises an error
# TODO: This could be better represented through overloads
_NormalizeableXArg: TypeAlias = str | ConvertibleToInt | Sequence[ConvertibleToInt]

# Constants
KEY_NAMES: list[str]
Expand Down Expand Up @@ -70,10 +74,10 @@ def size() -> Size: ...

resolution = size

def onScreen(x: _NormalizeableXArg | None, y: SupportsInt | None = None) -> bool: ...
def onScreen(x: _NormalizeableXArg | None, y: ConvertibleToInt | None = None) -> bool: ...
def mouseDown(
x: _NormalizeableXArg | None = None,
y: SupportsInt | None = None,
y: ConvertibleToInt | None = None,
# Docstring says `button` can also be `int`, but `.lower()` is called unconditionally in `_normalizeButton()`
button: str = "primary",
duration: float = 0.0,
Expand All @@ -83,7 +87,7 @@ def mouseDown(
) -> None: ...
def mouseUp(
x: _NormalizeableXArg | None = None,
y: SupportsInt | None = None,
y: ConvertibleToInt | None = None,
# Docstring says `button` can also be `int`, but `.lower()` is called unconditionally in `_normalizeButton()`
button: str = "primary",
duration: float = 0.0,
Expand All @@ -93,7 +97,7 @@ def mouseUp(
) -> None: ...
def click(
x: _NormalizeableXArg | None = None,
y: SupportsInt | None = None,
y: ConvertibleToInt | None = None,
clicks: SupportsIndex = 1,
interval: float = 0.0,
# Docstring says `button` can also be `int`, but `.lower()` is called unconditionally in `_normalizeButton()`
Expand All @@ -105,7 +109,7 @@ def click(
) -> None: ...
def leftClick(
x: _NormalizeableXArg | None = None,
y: SupportsInt | None = None,
y: ConvertibleToInt | None = None,
interval: float = 0.0,
duration: float = 0.0,
tween: Callable[[float], float] = ...,
Expand All @@ -114,7 +118,7 @@ def leftClick(
) -> None: ...
def rightClick(
x: _NormalizeableXArg | None = None,
y: SupportsInt | None = None,
y: ConvertibleToInt | None = None,
interval: float = 0.0,
duration: float = 0.0,
tween: Callable[[float], float] = ...,
Expand All @@ -123,7 +127,7 @@ def rightClick(
) -> None: ...
def middleClick(
x: _NormalizeableXArg | None = None,
y: SupportsInt | None = None,
y: ConvertibleToInt | None = None,
interval: float = 0.0,
duration: float = 0.0,
tween: Callable[[float], float] = ...,
Expand All @@ -132,7 +136,7 @@ def middleClick(
) -> None: ...
def doubleClick(
x: _NormalizeableXArg | None = None,
y: SupportsInt | None = None,
y: ConvertibleToInt | None = None,
interval: float = 0.0,
# Docstring says `button` can also be `int`, but `.lower()` is called unconditionally in `_normalizeButton()`
button: str = "left",
Expand All @@ -143,7 +147,7 @@ def doubleClick(
) -> None: ...
def tripleClick(
x: _NormalizeableXArg | None = None,
y: SupportsInt | None = None,
y: ConvertibleToInt | None = None,
interval: float = 0.0,
# Docstring says `button` can also be `int`, but `.lower()` is called unconditionally in `_normalizeButton()`
button: str = "left",
Expand All @@ -155,35 +159,35 @@ def tripleClick(
def scroll(
clicks: float,
x: _NormalizeableXArg | None = None,
y: SupportsInt | None = None,
y: ConvertibleToInt | None = None,
logScreenshot: bool | None = None,
_pause: bool = True,
) -> None: ...
def hscroll(
clicks: float,
x: _NormalizeableXArg | None = None,
y: SupportsInt | None = None,
y: ConvertibleToInt | None = None,
logScreenshot: bool | None = None,
_pause: bool = True,
) -> None: ...
def vscroll(
clicks: float,
x: _NormalizeableXArg | None = None,
y: SupportsInt | None = None,
y: ConvertibleToInt | None = None,
logScreenshot: bool | None = None,
_pause: bool = True,
) -> None: ...
def moveTo(
x: _NormalizeableXArg | None = None,
y: SupportsInt | None = None,
y: ConvertibleToInt | None = None,
duration: float = 0.0,
tween: Callable[[float], float] = ...,
logScreenshot: bool = False,
_pause: bool = True,
) -> None: ...
def moveRel(
xOffset: _NormalizeableXArg | None = None,
yOffset: SupportsInt | None = None,
yOffset: ConvertibleToInt | None = None,
duration: float = 0.0,
tween: Callable[[float], float] = ...,
logScreenshot: bool = False,
Expand All @@ -194,7 +198,7 @@ move = moveRel

def dragTo(
x: _NormalizeableXArg | None = None,
y: SupportsInt | None = None,
y: ConvertibleToInt | None = None,
duration: float = 0.0,
tween: Callable[[float], float] = ...,
# Docstring says `button` can also be `int`, but `.lower()` is called unconditionally in `_normalizeButton()`
Expand All @@ -205,7 +209,7 @@ def dragTo(
) -> None: ...
def dragRel(
xOffset: _NormalizeableXArg | None = 0,
yOffset: SupportsInt | None = 0,
yOffset: ConvertibleToInt | None = 0,
duration: float = 0.0,
tween: Callable[[float], float] = ...,
# Docstring says `button` can also be `int`, but `.lower()` is called unconditionally in `_normalizeButton()`
Expand Down
18 changes: 9 additions & 9 deletions stubs/PyScreeze/pyscreeze/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from _typeshed import Incomplete, ReadableBuffer, StrOrBytesPath, Unused
from _typeshed import ConvertibleToFloat, Incomplete, StrOrBytesPath, Unused
from collections.abc import Callable, Generator
from typing import NamedTuple, SupportsFloat, TypeVar, overload
from typing_extensions import Final, ParamSpec, SupportsIndex, TypeAlias
from typing import NamedTuple, TypeVar, overload
from typing_extensions import Final, ParamSpec, TypeAlias

from PIL import Image

Expand Down Expand Up @@ -48,7 +48,7 @@ def locate(
limit: Unused = 1,
region: tuple[int, int, int, int] | None = None,
step: int = 1,
confidence: SupportsFloat | SupportsIndex | str | ReadableBuffer = 0.999,
confidence: ConvertibleToFloat = 0.999,
) -> Box | None: ...

# _locateAll_pillow
Expand All @@ -74,7 +74,7 @@ def locateOnScreen(
limit: Unused = 1,
region: tuple[int, int, int, int] | None = None,
step: int = 1,
confidence: SupportsFloat | SupportsIndex | str | ReadableBuffer = 0.999,
confidence: ConvertibleToFloat = 0.999,
) -> Box | None: ...

# _locateAll_pillow
Expand All @@ -99,7 +99,7 @@ def locateAllOnScreen(
limit: int = 1000,
region: tuple[int, int, int, int] | None = None,
step: int = 1,
confidence: SupportsFloat | SupportsIndex | str | ReadableBuffer = 0.999,
confidence: ConvertibleToFloat = 0.999,
) -> Generator[Box, None, None]: ...

# _locateAll_pillow
Expand All @@ -124,7 +124,7 @@ def locateCenterOnScreen(
limit: Unused = 1,
region: tuple[int, int, int, int] | None = None,
step: int = 1,
confidence: SupportsFloat | SupportsIndex | str | ReadableBuffer = 0.999,
confidence: ConvertibleToFloat = 0.999,
) -> Point | None: ...

# _locateAll_pillow
Expand All @@ -151,7 +151,7 @@ def locateOnWindow(
grayscale: bool | None = None,
limit: Unused = 1,
step: int = 1,
confidence: SupportsFloat | SupportsIndex | str | ReadableBuffer = 0.999,
confidence: ConvertibleToFloat = 0.999,
) -> Box | None: ...

# _locateAll_pillow
Expand Down Expand Up @@ -184,7 +184,7 @@ def locateAll(
limit: int = 1000,
region: tuple[int, int, int, int] | None = None,
step: int = 1,
confidence: SupportsFloat | SupportsIndex | str | ReadableBuffer = 0.999,
confidence: ConvertibleToFloat = 0.999,
) -> Generator[Box, None, None]: ...

# _locateAll_pillow
Expand Down
5 changes: 3 additions & 2 deletions stubs/keyboard/keyboard/mouse.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import sys
from _typeshed import ConvertibleToInt
from collections.abc import Callable, Iterable
from ctypes import c_long
from typing import SupportsInt, TypeVar
from typing import TypeVar
from typing_extensions import Literal, TypeAlias

from ._generic import GenericListener as _GenericListener
Expand Down Expand Up @@ -42,7 +43,7 @@ def click(button: _MouseButton = "left") -> None: ...
def double_click(button: _MouseButton = "left") -> None: ...
def right_click() -> None: ...
def wheel(delta: int = 1) -> None: ...
def move(x: SupportsInt, y: SupportsInt, absolute: bool = True, duration: float = 0) -> None: ...
def move(x: ConvertibleToInt, y: ConvertibleToInt, absolute: bool = True, duration: float = 0) -> None: ...
def drag(start_x: int, start_y: int, end_x: int, end_y: int, absolute: bool = True, duration: float = 0) -> None: ...
def on_button(
callback: Callable[..., None],
Expand Down
11 changes: 5 additions & 6 deletions stubs/libsass/sass.pyi
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import enum
from _typeshed import ReadableBuffer, SupportsKeysAndGetItem
from _typeshed import ConvertibleToFloat, SupportsKeysAndGetItem
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence, Set as AbstractSet
from typing import Any, Generic, NamedTuple, SupportsFloat, TypeVar, overload, type_check_only
from typing_extensions import Literal, ParamSpec, Self, SupportsIndex, TypeAlias
from typing import Any, Generic, NamedTuple, TypeVar, overload, type_check_only
from typing_extensions import Literal, ParamSpec, Self, TypeAlias

_T = TypeVar("_T")
_KT = TypeVar("_KT")
_VT_co = TypeVar("_VT_co", covariant=True)
_P = ParamSpec("_P")
_Mode: TypeAlias = Literal["string", "filename", "dirname"]
_OutputStyle: TypeAlias = Literal["nested", "expanded", "compact", "compressed"]
_ConvertsToFloat: TypeAlias = SupportsFloat | SupportsIndex | str | ReadableBuffer
_CustomFunctions: TypeAlias = Mapping[str, Callable[..., Any]] | Sequence[Callable[..., Any]] | AbstractSet[Callable[..., Any]]
_ImportCallbackRet: TypeAlias = (
list[tuple[str, str, str]] | list[tuple[str, str]] | list[tuple[str]] | list[tuple[str, ...]] | None
Expand Down Expand Up @@ -113,7 +112,7 @@ class _SassNumber(NamedTuple):
unit: str

class SassNumber(_SassNumber):
def __new__(cls, value: _ConvertsToFloat, unit: str | bytes) -> Self: ...
def __new__(cls, value: ConvertibleToFloat, unit: str | bytes) -> Self: ...

@type_check_only
class _SassColor(NamedTuple):
Expand All @@ -123,7 +122,7 @@ class _SassColor(NamedTuple):
a: float

class SassColor(_SassColor):
def __new__(cls, r: _ConvertsToFloat, g: _ConvertsToFloat, b: _ConvertsToFloat, a: _ConvertsToFloat) -> Self: ...
def __new__(cls, r: ConvertibleToFloat, g: ConvertibleToFloat, b: ConvertibleToFloat, a: ConvertibleToFloat) -> Self: ...

@type_check_only
class _Separator(enum.Enum):
Expand Down
9 changes: 5 additions & 4 deletions stubs/netaddr/netaddr/eui/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import ClassVar, SupportsInt, overload
from typing_extensions import Literal, Self, SupportsIndex
from _typeshed import ConvertibleToInt
from typing import ClassVar, overload
from typing_extensions import Literal, Self

from netaddr.core import DictDotLookup
from netaddr.ip import IPAddress
Expand Down Expand Up @@ -40,7 +41,7 @@ class EUI(BaseIdentifier):
@property
def value(self) -> int: ...
@value.setter
def value(self, value: str | SupportsInt | SupportsIndex) -> None: ...
def value(self, value: ConvertibleToInt) -> None: ...
@property
def dialect(self) -> type[mac_eui48 | eui64_base]: ...
@dialect.setter
Expand Down Expand Up @@ -77,7 +78,7 @@ class EUI(BaseIdentifier):
def bin(self) -> str: ...
def eui64(self) -> Self: ...
def modified_eui64(self) -> Self: ...
def ipv6(self, prefix: str | SupportsInt | SupportsIndex) -> IPAddress: ...
def ipv6(self, prefix: ConvertibleToInt) -> IPAddress: ...
def ipv6_link_local(self) -> IPAddress: ...
@property
def info(self) -> DictDotLookup: ...
Expand Down
14 changes: 7 additions & 7 deletions stubs/netaddr/netaddr/ip/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from _typeshed import Incomplete, Unused
from _typeshed import ConvertibleToInt, Incomplete, Unused
from abc import abstractmethod
from collections.abc import Iterable, Iterator
from typing import SupportsInt, overload
from typing import overload
from typing_extensions import Literal, Self, SupportsIndex, TypeAlias

from netaddr.core import DictDotLookup
Expand Down Expand Up @@ -71,9 +71,9 @@ class IPAddress(BaseIP):
def ipv4(self) -> Self: ...
def ipv6(self, ipv4_compatible: bool = False) -> Self: ...
def format(self, dialect: type[ipv6_verbose] | None = None) -> str: ...
def __or__(self, other: str | SupportsInt | SupportsIndex) -> Self: ...
def __and__(self, other: str | SupportsInt | SupportsIndex) -> Self: ...
def __xor__(self, other: str | SupportsInt | SupportsIndex) -> Self: ...
def __or__(self, other: ConvertibleToInt) -> Self: ...
def __and__(self, other: ConvertibleToInt) -> Self: ...
def __xor__(self, other: ConvertibleToInt) -> Self: ...
def __lshift__(self, numbits: int) -> Self: ...
def __rshift__(self, numbits: int) -> Self: ...
def __bool__(self) -> bool: ...
Expand Down Expand Up @@ -148,14 +148,14 @@ class IPRange(BaseIP, IPListMixin):
def cidrs(self) -> list[IPNetwork]: ...

def iter_unique_ips(*args: IPRange | _IPNetworkAddr) -> Iterator[IPAddress]: ...
def cidr_abbrev_to_verbose(abbrev_cidr: str | SupportsInt | SupportsIndex) -> str: ...
def cidr_abbrev_to_verbose(abbrev_cidr: ConvertibleToInt) -> str: ...
def cidr_merge(ip_addrs: Iterable[IPRange | _IPNetworkAddr]) -> list[IPNetwork]: ...
def cidr_exclude(target: _IPNetworkAddr, exclude: _IPNetworkAddr) -> list[IPNetwork]: ...
def cidr_partition(
target: _IPNetworkAddr, exclude: _IPNetworkAddr
) -> tuple[list[IPNetwork], list[IPNetwork], list[IPNetwork]]: ...
def spanning_cidr(ip_addrs: Iterable[_IPNetworkAddr]) -> IPNetwork: ...
def iter_iprange(start: _IPAddressAddr, end: _IPAddressAddr, step: SupportsInt | SupportsIndex = 1) -> Iterator[IPAddress]: ...
def iter_iprange(start: _IPAddressAddr, end: _IPAddressAddr, step: ConvertibleToInt = 1) -> Iterator[IPAddress]: ...
def iprange_to_cidrs(start: _IPNetworkAddr, end: _IPNetworkAddr) -> list[IPNetwork]: ...
def smallest_matching_cidr(ip: _IPAddressAddr, cidrs: Iterable[_IPNetworkAddr]) -> IPNetwork | None: ...
def largest_matching_cidr(ip: _IPAddressAddr, cidrs: Iterable[_IPNetworkAddr]) -> IPNetwork | None: ...
Expand Down
14 changes: 7 additions & 7 deletions stubs/openpyxl/openpyxl/cell/text.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from _typeshed import Incomplete
from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete
from typing import ClassVar
from typing_extensions import Literal, TypeAlias

from openpyxl.descriptors.base import Alias, Integer, NoneSet, Typed, _ConvertibleToBool, _ConvertibleToFloat, _ConvertibleToInt
from openpyxl.descriptors.base import Alias, Integer, NoneSet, Typed, _ConvertibleToBool
from openpyxl.descriptors.nested import NestedString, NestedText, _NestedNoneSetParam
from openpyxl.descriptors.serialisable import Serialisable
from openpyxl.styles.colors import Color
Expand All @@ -20,7 +20,7 @@ class PhoneticProperties(Serialisable):
alignment: NoneSet[_PhoneticPropertiesAlignment]
def __init__(
self,
fontId: _ConvertibleToInt,
fontId: ConvertibleToInt,
type: _PhoneticPropertiesType | Literal["none"] | None = None,
alignment: _PhoneticPropertiesAlignment | Literal["none"] | None = None,
) -> None: ...
Expand All @@ -33,7 +33,7 @@ class PhoneticText(Serialisable):
eb: Integer[Literal[False]]
t: NestedText[str, Literal[False]]
text: Alias
def __init__(self, sb: _ConvertibleToInt, eb: _ConvertibleToInt, t: object = None) -> None: ...
def __init__(self, sb: ConvertibleToInt, eb: ConvertibleToInt, t: object = None) -> None: ...

class InlineFont(Font):
tagname: ClassVar[str]
Expand All @@ -57,8 +57,8 @@ class InlineFont(Font):
def __init__(
self,
rFont: object = None,
charset: _HasTagAndGet[_ConvertibleToInt | None] | _ConvertibleToInt | None = None,
family: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None,
charset: _HasTagAndGet[ConvertibleToInt | None] | ConvertibleToInt | None = None,
family: _HasTagAndGet[ConvertibleToFloat | None] | ConvertibleToFloat | None = None,
b: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None,
i: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool = None,
strike: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None,
Expand All @@ -67,7 +67,7 @@ class InlineFont(Font):
condense: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None,
extend: _HasTagAndGet[_ConvertibleToBool | None] | _ConvertibleToBool | None = None,
color: Color | None = None,
sz: _HasTagAndGet[_ConvertibleToFloat | None] | _ConvertibleToFloat | None = None,
sz: _HasTagAndGet[ConvertibleToFloat | None] | ConvertibleToFloat | None = None,
u: _NestedNoneSetParam[_FontU] = None,
vertAlign: _NestedNoneSetParam[_FontVertAlign] = None,
scheme: _NestedNoneSetParam[_FontScheme] = None,
Expand Down
Loading