summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorSebastian Berg <sebastianb@nvidia.com>2023-03-14 17:13:05 +0100
committerGitHub <noreply@github.com>2023-03-14 17:13:05 +0100
commita95741d546aad3dd024077e4fdfb147314514f48 (patch)
tree85ce0ad117158f8712bc4aa25030f0c3586784b5 /numpy
parent071388f957c13c1a4f03bc811e3d128335ac686e (diff)
parente570c6f5ff6f5aa966193d51560d3cde30fc09bd (diff)
downloadnumpy-a95741d546aad3dd024077e4fdfb147314514f48.tar.gz
Merge pull request #23384 from neutrinoceros/cleanup_py38
MAINT: cleanup unused Python3.8-only code and references
Diffstat (limited to 'numpy')
-rw-r--r--numpy/__init__.pyi11
-rw-r--r--numpy/array_api/_typing.py31
-rw-r--r--numpy/core/tests/test_dtype.py8
-rw-r--r--numpy/core/tests/test_scalar_methods.py10
-rw-r--r--numpy/distutils/mingw32ccompiler.py5
-rw-r--r--numpy/typing/tests/data/reveal/scalars.pyi6
-rw-r--r--numpy/typing/tests/test_runtime.py6
7 files changed, 21 insertions, 56 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi
index f909005b1..ee5fbb601 100644
--- a/numpy/__init__.pyi
+++ b/numpy/__init__.pyi
@@ -1,19 +1,15 @@
import builtins
import os
-import sys
import mmap
import ctypes as ct
import array as _array
import datetime as dt
import enum
from abc import abstractmethod
-from types import TracebackType, MappingProxyType
+from types import TracebackType, MappingProxyType, GenericAlias
from contextlib import ContextDecorator
from contextlib import contextmanager
-if sys.version_info >= (3, 9):
- from types import GenericAlias
-
from numpy._pytesttester import PytestTester
from numpy.core._internal import _ctypes
@@ -2978,9 +2974,8 @@ class floating(inexact[_NBit1]):
@classmethod
def fromhex(cls: type[float64], string: str, /) -> float64: ...
def as_integer_ratio(self) -> tuple[int, int]: ...
- if sys.version_info >= (3, 9):
- def __ceil__(self: float64) -> int: ...
- def __floor__(self: float64) -> int: ...
+ def __ceil__(self: float64) -> int: ...
+ def __floor__(self: float64) -> int: ...
def __trunc__(self: float64) -> int: ...
def __getnewargs__(self: float64) -> tuple[float]: ...
def __getformat__(self: float64, typestr: L["double", "float"], /) -> str: ...
diff --git a/numpy/array_api/_typing.py b/numpy/array_api/_typing.py
index dfa87b358..3f9b7186a 100644
--- a/numpy/array_api/_typing.py
+++ b/numpy/array_api/_typing.py
@@ -17,14 +17,12 @@ __all__ = [
"PyCapsule",
]
-import sys
from typing import (
Any,
Literal,
Sequence,
Type,
Union,
- TYPE_CHECKING,
TypeVar,
Protocol,
)
@@ -51,21 +49,20 @@ class NestedSequence(Protocol[_T_co]):
def __len__(self, /) -> int: ...
Device = Literal["cpu"]
-if TYPE_CHECKING or sys.version_info >= (3, 9):
- Dtype = dtype[Union[
- int8,
- int16,
- int32,
- int64,
- uint8,
- uint16,
- uint32,
- uint64,
- float32,
- float64,
- ]]
-else:
- Dtype = dtype
+
+Dtype = dtype[Union[
+ int8,
+ int16,
+ int32,
+ int64,
+ uint8,
+ uint16,
+ uint32,
+ uint64,
+ float32,
+ float64,
+]]
+
SupportsBufferProtocol = Any
PyCapsule = Any
diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py
index 9b44367e6..f764a4daa 100644
--- a/numpy/core/tests/test_dtype.py
+++ b/numpy/core/tests/test_dtype.py
@@ -1833,7 +1833,6 @@ class TestUserDType:
create_custom_field_dtype(blueprint, mytype, 2)
-@pytest.mark.skipif(sys.version_info < (3, 9), reason="Requires python 3.9")
class TestClassGetItem:
def test_dtype(self) -> None:
alias = np.dtype[Any]
@@ -1866,10 +1865,3 @@ def test_result_type_integers_and_unitless_timedelta64():
td = np.timedelta64(4)
result = np.result_type(0, td)
assert_dtype_equal(result, td.dtype)
-
-
-@pytest.mark.skipif(sys.version_info >= (3, 9), reason="Requires python 3.8")
-def test_class_getitem_38() -> None:
- match = "Type subscription requires python >= 3.9"
- with pytest.raises(TypeError, match=match):
- np.dtype[Any]
diff --git a/numpy/core/tests/test_scalar_methods.py b/numpy/core/tests/test_scalar_methods.py
index 4f57c94c0..18a7bc828 100644
--- a/numpy/core/tests/test_scalar_methods.py
+++ b/numpy/core/tests/test_scalar_methods.py
@@ -1,7 +1,6 @@
"""
Test the scalar constructors, which also do type-coercion
"""
-import sys
import fractions
import platform
import types
@@ -134,7 +133,6 @@ class TestIsInteger:
assert not value.is_integer()
-@pytest.mark.skipif(sys.version_info < (3, 9), reason="Requires python 3.9")
class TestClassGetItem:
@pytest.mark.parametrize("cls", [
np.number,
@@ -188,14 +186,6 @@ class TestClassGetItem:
assert np.number[Any]
-@pytest.mark.skipif(sys.version_info >= (3, 9), reason="Requires python 3.8")
-@pytest.mark.parametrize("cls", [np.number, np.complexfloating, np.int64])
-def test_class_getitem_38(cls: Type[np.number]) -> None:
- match = "Type subscription requires python >= 3.9"
- with pytest.raises(TypeError, match=match):
- cls[Any]
-
-
class TestBitCount:
# derived in part from the cpython test "test_bit_count"
diff --git a/numpy/distutils/mingw32ccompiler.py b/numpy/distutils/mingw32ccompiler.py
index f42dfdc9b..4763f41ad 100644
--- a/numpy/distutils/mingw32ccompiler.py
+++ b/numpy/distutils/mingw32ccompiler.py
@@ -206,10 +206,7 @@ def find_python_dll():
if implementation == 'cpython':
dllname = f'python{major_version}{minor_version}.dll'
elif implementation == 'pypy':
- if sys.version_info >= (3, 9):
- dllname = f'libpypy{major_version}.{minor_version}-c.dll'
- else:
- dllname = f'libpypy{major_version}-c.dll'
+ dllname = f'libpypy{major_version}.{minor_version}-c.dll'
else:
dllname = f'Unknown platform {implementation}'
print("Looking for %s" % dllname)
diff --git a/numpy/typing/tests/data/reveal/scalars.pyi b/numpy/typing/tests/data/reveal/scalars.pyi
index b7fc75acc..965aa5ace 100644
--- a/numpy/typing/tests/data/reveal/scalars.pyi
+++ b/numpy/typing/tests/data/reveal/scalars.pyi
@@ -1,4 +1,3 @@
-import sys
import numpy as np
b: np.bool_
@@ -151,8 +150,7 @@ reveal_type(round(u8, 3)) # E: {uint64}
reveal_type(round(f8)) # E: int
reveal_type(round(f8, 3)) # E: {float64}
-if sys.version_info >= (3, 9):
- reveal_type(f8.__ceil__()) # E: int
- reveal_type(f8.__floor__()) # E: int
+reveal_type(f8.__ceil__()) # E: int
+reveal_type(f8.__floor__()) # E: int
reveal_type(i8.is_integer()) # E: Literal[True]
diff --git a/numpy/typing/tests/test_runtime.py b/numpy/typing/tests/test_runtime.py
index 44d069006..c32c5db32 100644
--- a/numpy/typing/tests/test_runtime.py
+++ b/numpy/typing/tests/test_runtime.py
@@ -2,7 +2,6 @@
from __future__ import annotations
-import sys
from typing import (
get_type_hints,
Union,
@@ -24,10 +23,7 @@ class TypeTup(NamedTuple):
origin: None | type
-if sys.version_info >= (3, 9):
- NDArrayTup = TypeTup(npt.NDArray, npt.NDArray.__args__, np.ndarray)
-else:
- NDArrayTup = TypeTup(npt.NDArray, (), None)
+NDArrayTup = TypeTup(npt.NDArray, npt.NDArray.__args__, np.ndarray)
TYPES = {
"ArrayLike": TypeTup(npt.ArrayLike, npt.ArrayLike.__args__, Union),