Skip to content

Commit 2d19014

Browse files
committed
🐴 simplified sys.platform checks
1 parent 500bb2d commit 2d19014

9 files changed

Lines changed: 17 additions & 17 deletions

File tree

src/numpy-stubs/@test/static/accept/testing.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ assert_type(np.testing.break_cycles(), None)
165165

166166
# NOTE: Platform-dependent behavior cannot be tested on pyright
167167
# ruff: noqa: ERA001
168-
169-
# if sys.platform == "win32" or sys.platform == "cygwin":
168+
# if sys.platform == "win32":
170169
# assert_type(np.testing.memusage(), int)
171170
# elif sys.platform == "linux":
172171
# assert_type(np.testing.memusage(), int | None)

src/numpy-stubs/__init__.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ __all__: list[str] = [ # noqa: RUF022
596596
"__version__",
597597
] # fmt: skip
598598

599-
if sys.platform == "win32" or sys.platform == "cygwin":
599+
if sys.platform == "win32":
600600
__all__ += ["complex192", "float96"]
601601
else:
602602
__all__ += ["complex256", "float128"]
@@ -4704,7 +4704,7 @@ class longdouble(_FloatMixin[L[12, 16]], floating):
47044704
@override
47054705
def tolist(self, /) -> Self: ... # pyright: ignore[reportIncompatibleMethodOverride]
47064706

4707-
if sys.platform == "win32" or sys.platform == "cygwin":
4707+
if sys.platform == "win32":
47084708
float96 = longdouble
47094709
else:
47104710
float128 = longdouble
@@ -4894,7 +4894,7 @@ class clongdouble(complexfloating):
48944894
#
48954895
def __complex__(self, /) -> complex: ...
48964896

4897-
if sys.platform == "win32" or sys.platform == "cygwin":
4897+
if sys.platform == "win32":
48984898
complex192 = clongdouble
48994899
else:
49004900
complex256 = clongdouble

src/numpy-stubs/_core/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ __all__: list[str] = [
641641
"zeros_like",
642642
]
643643

644-
if sys.platform == "win32" or sys.platform == "cygwin":
644+
if sys.platform == "win32":
645645
from .numerictypes import complex192, float96
646646

647647
__all__ += ["complex192", "float96"]

src/numpy-stubs/_core/numeric.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ __all__: list[str] = [
583583
"zeros_like",
584584
]
585585

586-
if sys.platform == "win32" or sys.platform == "cygwin":
586+
if sys.platform == "win32":
587587
from .numerictypes import complex192, float96
588588

589589
__all__ += ["complex192", "float96"]

src/numpy-stubs/_core/numerictypes.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ __all__: list[str] = [
131131
"void",
132132
]
133133

134-
if sys.platform == "win32" or sys.platform == "cygwin":
134+
if sys.platform == "win32":
135135
from numpy import complex192, float96
136136

137137
__all__ += ["complex192", "float96"]

src/numpy-stubs/core/numeric.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ from numpy._core.numeric import (
292292
zeros_like,
293293
)
294294

295-
__all__ = [
295+
# pyright needs the `list[str]` annotation here
296+
__all__: list[str] = [
296297
"False_",
297298
"ScalarType",
298299
"True_",
@@ -585,7 +586,7 @@ __all__ = [
585586
"zeros_like",
586587
]
587588

588-
if sys.platform == "win32" or sys.platform == "cygwin":
589+
if sys.platform == "win32":
589590
from numpy._core.numeric import complex192, float96
590591

591592
__all__ += ["complex192", "float96"]

src/numpy-stubs/core/numerictypes.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ from numpy._core.numerictypes import (
6565
void,
6666
)
6767

68-
__all__ = [ # noqa: RUF022
68+
# pyright needs the `list[str]` annotation here
69+
__all__: list[str] = [ # noqa: RUF022
6970
"ScalarType",
7071
"typecodes",
7172
"isdtype",
@@ -130,7 +131,7 @@ __all__ = [ # noqa: RUF022
130131
"timedelta64",
131132
]
132133

133-
if sys.platform == "win32" or sys.platform == "cygwin":
134+
if sys.platform == "win32":
134135
from numpy._core.numerictypes import complex192, float96
135136

136137
__all__ += ["complex192", "float96"]

src/numpy-stubs/matlib.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ __all__ += [ # noqa: RUF022
600600
"__version__",
601601
] # fmt: skip
602602

603-
if sys.platform == "win32" or sys.platform == "cygwin":
603+
if sys.platform == "win32":
604604
from numpy import complex192, float96
605605

606606
__all__ += ["complex192", "float96"]

src/numpy-stubs/testing/_private/utils.pyi

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,11 @@ class suppress_warnings:
160160
self, /, category: type[Warning] = ..., message: str = "", module: types.ModuleType | None = None
161161
) -> _WarnLog: ...
162162

163-
# Contrary to runtime we can't do `os.name` checks while type checking,
164-
# only `sys.platform` checks
165-
if sys.platform != "win32" and sys.platform != "cygwin" and sys.platform != "linux":
163+
# At runtime `os.name` is used, but static type checkers only support a small subset of `sys.platform` checks.
164+
if sys.platform != "win32" and sys.platform != "linux":
166165
def memusage() -> NoReturn: ...
167166

168-
elif sys.platform == "win32" or sys.platform == "cygwin":
167+
elif sys.platform == "win32":
169168
def memusage(processName: str = "python", instance: int = 0) -> int: ...
170169

171170
else:

0 commit comments

Comments
 (0)