Skip to content

Commit 91b35bb

Browse files
authored
Review SupportsInt and SupportsFloat usages in 3rd-party stubs (#11003)
1 parent fd3228a commit 91b35bb

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

stubs/PyAutoGUI/pyautogui/__init__.pyi

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import contextlib
2+
from _typeshed import ConvertibleToInt
23
from collections.abc import Callable, Iterable, Sequence
34
from datetime import datetime
45
from typing import NamedTuple, SupportsInt, TypeVar
@@ -19,7 +20,10 @@ from pyscreeze import (
1920

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

2428
# Constants
2529
KEY_NAMES: list[str]

stubs/netaddr/netaddr/eui/__init__.pyi

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from typing import ClassVar, SupportsInt, overload
2-
from typing_extensions import Literal, Self, SupportsIndex
1+
from _typeshed import ConvertibleToInt
2+
from typing import ClassVar, overload
3+
from typing_extensions import Literal, Self
34

45
from netaddr.core import DictDotLookup
56
from netaddr.ip import IPAddress
@@ -40,7 +41,7 @@ class EUI(BaseIdentifier):
4041
@property
4142
def value(self) -> int: ...
4243
@value.setter
43-
def value(self, value: str | SupportsInt | SupportsIndex) -> None: ...
44+
def value(self, value: ConvertibleToInt) -> None: ...
4445
@property
4546
def dialect(self) -> type[mac_eui48 | eui64_base]: ...
4647
@dialect.setter
@@ -77,7 +78,7 @@ class EUI(BaseIdentifier):
7778
def bin(self) -> str: ...
7879
def eui64(self) -> Self: ...
7980
def modified_eui64(self) -> Self: ...
80-
def ipv6(self, prefix: str | SupportsInt | SupportsIndex) -> IPAddress: ...
81+
def ipv6(self, prefix: ConvertibleToInt) -> IPAddress: ...
8182
def ipv6_link_local(self) -> IPAddress: ...
8283
@property
8384
def info(self) -> DictDotLookup: ...

stubs/netaddr/netaddr/ip/__init__.pyi

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from _typeshed import Incomplete, Unused
1+
from _typeshed import ConvertibleToInt, Incomplete, Unused
22
from abc import abstractmethod
33
from collections.abc import Iterable, Iterator
44
from typing import SupportsInt, overload
@@ -71,9 +71,9 @@ class IPAddress(BaseIP):
7171
def ipv4(self) -> Self: ...
7272
def ipv6(self, ipv4_compatible: bool = False) -> Self: ...
7373
def format(self, dialect: type[ipv6_verbose] | None = None) -> str: ...
74-
def __or__(self, other: str | SupportsInt | SupportsIndex) -> Self: ...
75-
def __and__(self, other: str | SupportsInt | SupportsIndex) -> Self: ...
76-
def __xor__(self, other: str | SupportsInt | SupportsIndex) -> Self: ...
74+
def __or__(self, other: SupportsInt | SupportsIndex) -> Self: ...
75+
def __and__(self, other: SupportsInt | SupportsIndex) -> Self: ...
76+
def __xor__(self, other: SupportsInt | SupportsIndex) -> Self: ...
7777
def __lshift__(self, numbits: int) -> Self: ...
7878
def __rshift__(self, numbits: int) -> Self: ...
7979
def __bool__(self) -> bool: ...
@@ -148,7 +148,7 @@ class IPRange(BaseIP, IPListMixin):
148148
def cidrs(self) -> list[IPNetwork]: ...
149149

150150
def iter_unique_ips(*args: IPRange | _IPNetworkAddr) -> Iterator[IPAddress]: ...
151-
def cidr_abbrev_to_verbose(abbrev_cidr: str | SupportsInt | SupportsIndex) -> str: ...
151+
def cidr_abbrev_to_verbose(abbrev_cidr: ConvertibleToInt) -> str: ...
152152
def cidr_merge(ip_addrs: Iterable[IPRange | _IPNetworkAddr]) -> list[IPNetwork]: ...
153153
def cidr_exclude(target: _IPNetworkAddr, exclude: _IPNetworkAddr) -> list[IPNetwork]: ...
154154
def cidr_partition(

0 commit comments

Comments
 (0)