Content-Length: 1299756 | pFad | http://github.com/numpy/numpy/pull/27309/files

43 MNT: Enforce ruff/Pyflakes rules (F) by DimitriPapadopoulos · Pull Request #27309 · numpy/numpy · GitHub
Skip to content

MNT: Enforce ruff/Pyflakes rules (F) #27309

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

Merged
merged 7 commits into from
May 12, 2025
Merged
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
2 changes: 1 addition & 1 deletion .spin/cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def check_docs(*, parent_callback, pytest_args, **kwargs):
""" # noqa: E501
try:
# prevent obscure error later
import scipy_doctest
import scipy_doctest # noqa: F401
except ModuleNotFoundError as e:
raise ModuleNotFoundError("scipy-doctest not installed") from e

Expand Down
4 changes: 2 additions & 2 deletions benchmarks/benchmarks/bench_array_coercion.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def time_asarray(self, array_like):
def time_asarray_dtype(self, array_like):
np.asarray(array_like, dtype=self.int64)

def time_asarray_dtype(self, array_like):
def time_asarray_dtype_order(self, array_like):
np.asarray(array_like, dtype=self.int64, order="F")

def time_asanyarray(self, array_like):
Expand All @@ -47,7 +47,7 @@ def time_asanyarray(self, array_like):
def time_asanyarray_dtype(self, array_like):
np.asanyarray(array_like, dtype=self.int64)

def time_asanyarray_dtype(self, array_like):
def time_asanyarray_dtype_order(self, array_like):
np.asanyarray(array_like, dtype=self.int64, order="F")

def time_ascontiguousarray(self, array_like):
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmarks/bench_manipulate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .common import Benchmark, get_squares_, TYPES1, DLPACK_TYPES
from .common import Benchmark, TYPES1

import numpy as np
from collections import deque
Expand Down
3 changes: 0 additions & 3 deletions numpy/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,6 @@ from numpy.lib._function_base_impl import (
place,
asarray_chkfinite,
average,
bincount,
digitize,
cov,
corrcoef,
Expand Down Expand Up @@ -545,8 +544,6 @@ from numpy.lib._npyio_impl import (
save,
savez,
savez_compressed,
packbits,
unpackbits,
fromregex,
)

Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/_add_newdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"""

from numpy._core.function_base import add_newdoc
from numpy._core.overrides import get_array_function_like_doc
from numpy._core.overrides import get_array_function_like_doc # noqa: F401


###############################################################################
Expand Down
1 change: 0 additions & 1 deletion numpy/_core/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
By putting the formatting in `__str__`, we also avoid paying the cost for
users who silence the exceptions.
"""
from numpy._utils import set_module

def _unpack_tuple(tup):
if len(tup) == 1:
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import warnings

from numpy.exceptions import DTypePromotionError
from .multiarray import dtype, array, ndarray, promote_types, StringDType
from .multiarray import dtype, array, promote_types, StringDType
from numpy import _NoValue
try:
import ctypes
Expand Down
1 change: 0 additions & 1 deletion numpy/_core/_machar.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from .fromnumeric import any
from ._ufunc_config import errstate
from numpy._utils import set_module

# Need to speed this up...especially for longdouble

Expand Down
1 change: 0 additions & 1 deletion numpy/_core/_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from numpy._core import umath as um
from numpy._core.multiarray import asanyarray
from numpy._core import numerictypes as nt
from numpy._core import _exceptions
from numpy._globals import _NoValue

# save those O(100) nanoseconds!
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/_type_aliases.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Collection
from typing import Any, Final, Literal as L, TypeAlias, TypedDict, type_check_only
from typing import Final, Literal as L, TypeAlias, TypedDict, type_check_only

import numpy as np

Expand Down
2 changes: 0 additions & 2 deletions numpy/_core/_ufunc_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
This provides helpers which wrap `_get_extobj_dict` and `_make_extobj`, and
`_extobj_contextvar` from umath.
"""
import contextlib
import contextvars
import functools

from numpy._utils import set_module
Expand Down
4 changes: 1 addition & 3 deletions numpy/_core/arrayprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@
import numpy as np
from . import numerictypes as _nt
from .umath import absolute, isinf, isfinite, isnat
from . import multiarray
from .multiarray import (array, dragon4_positional, dragon4_scientific,
datetime_as_string, datetime_data, ndarray)
from .fromnumeric import any
from .numeric import concatenate, asarray, errstate
from .numerictypes import (longlong, intc, int_, float64, complex128,
flexible)
from .numerictypes import int_, float64, complex128, flexible
from .overrides import array_function_dispatch, set_module
from .printoptions import format_options
import operator
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/fromnumeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from . import overrides
from . import umath as um
from . import numerictypes as nt
from .multiarray import asarray, array, asanyarray, concatenate
from .multiarray import asarray, asanyarray, concatenate
from ._multiarray_umath import _array_converter
from . import _methods

Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/multiarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# These imports are needed for backward compatibility,
# do not change them. issue gh-15518
# _get_ndarray_c_version is semi-public, on purpose not added to __all__
from ._multiarray_umath import (
from ._multiarray_umath import ( # noqa: F401
_flagdict, from_dlpack, _place, _reconstruct,
_vec_string, _ARRAY_API, _monotonicity, _get_ndarray_c_version,
_get_madvise_hugepage, _set_madvise_hugepage,
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy as np
from . import multiarray
from . import numerictypes as nt
from .multiarray import (
from .multiarray import ( # noqa: F401
ALLOW_THREADS, BUFSIZE, CLIP, MAXDIMS, MAY_SHARE_BOUNDS, MAY_SHARE_EXACT,
RAISE, WRAP, arange, array, asarray, asanyarray, ascontiguousarray,
asfortranarray, broadcast, can_cast, concatenate, copyto, dot, dtype,
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import collections
import functools

from numpy._utils import set_module
from numpy._utils import set_module # noqa: F401
from numpy._utils._inspect import getargspec
from numpy._core._multiarray_umath import (
add_docstring, _get_implementing_args, _ArrayFunctionDispatcher)
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/strings.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, overload, TypeAlias
from typing import overload, TypeAlias

import numpy as np
from numpy._typing import (
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/tests/test_array_coercion.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from numpy._core._rational_tests import rational

from numpy.testing import (
assert_array_equal, assert_warns, IS_PYPY, IS_64BIT
assert_array_equal, IS_PYPY, IS_64BIT
)


Expand Down
2 changes: 0 additions & 2 deletions numpy/_core/tests/test_conversion_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
Tests for numpy/_core/src/multiarray/conversion_utils.c
"""
import re
import sys

import pytest

import numpy as np
import numpy._core._multiarray_tests as mt
from numpy._core.multiarray import CLIP, WRAP, RAISE
from numpy.testing import assert_raises
Expand Down
1 change: 0 additions & 1 deletion numpy/_core/tests/test_cpu_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
__cpu_baseline__,
__cpu_dispatch__,
)
import numpy as np

def assert_features_equal(actual, desired, fname):
__tracebackhide__ = True # Hide traceback for py.test
Expand Down
9 changes: 3 additions & 6 deletions numpy/_core/tests/test_deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,17 @@
"""
import warnings
import pytest
import tempfile
import re

import numpy as np
from numpy.testing import (
assert_raises, assert_warns, assert_, assert_array_equal, SkipTest,
KnownFailureException, break_cycles, temppath
assert_raises, temppath
)

from numpy._core._multiarray_tests import fromstring_null_term_c_api
from numpy._core._multiarray_tests import fromstring_null_term_c_api # noqa: F401
import numpy._core._struct_ufunc_tests as struct_ufunc

try:
import pytz
import pytz # noqa: F401
_has_pytz = True
except ImportError:
_has_pytz = False
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/tests/test_errstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sysconfig

import numpy as np
from numpy.testing import assert_, assert_raises, IS_WASM
from numpy.testing import assert_raises, IS_WASM

# The floating point emulation on ARM EABI systems lacking a hardware FPU is
# known to be buggy. This is an attempt to identify these hosts. It may not
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from numpy.exceptions import ComplexWarning, VisibleDeprecationWarning
from numpy.testing import (
assert_, assert_equal, assert_raises, assert_raises_regex,
assert_array_equal, assert_warns, HAS_REFCOUNT, IS_WASM
assert_array_equal, assert_warns, HAS_REFCOUNT
)


Expand Down
6 changes: 3 additions & 3 deletions numpy/_core/tests/test_limited_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ def test_limited_api(install_temp):
and building a cython extension with the limited API
"""

import limited_api1 # Earliest (3.6)
import limited_api_latest # Latest version (current Python)
import limited_api2 # cython
import limited_api1 # Earliest (3.6) # noqa: F401
import limited_api_latest # Latest version (current Python) # noqa: F401
import limited_api2 # cython # noqa: F401
2 changes: 1 addition & 1 deletion numpy/_core/tests/test_longdouble.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import numpy as np
from numpy.testing import (
assert_, assert_equal, assert_raises, assert_warns, assert_array_equal,
assert_, assert_equal, assert_raises, assert_array_equal,
temppath, IS_MUSL
)
from numpy._core.tests._locales import CommaDecimalPointLocale
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/tests/test_nditer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from numpy import array, arange, nditer, all
from numpy.testing import (
assert_, assert_equal, assert_array_equal, assert_raises,
IS_WASM, HAS_REFCOUNT, suppress_warnings, break_cycles,
IS_WASM, HAS_REFCOUNT, suppress_warnings,
)
from numpy.testing._private.utils import requires_memory

Expand Down
4 changes: 2 additions & 2 deletions numpy/_core/tests/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
from decimal import Decimal

import numpy as np
from numpy._core import umath, sctypes
from numpy._core import sctypes
from numpy._core.numerictypes import obj2sctype
from numpy.exceptions import AxisError
from numpy.random import rand, randint, randn
from numpy.testing import (
assert_, assert_equal, assert_raises, assert_raises_regex,
assert_array_equal, assert_almost_equal, assert_array_almost_equal,
assert_warns, assert_array_max_ulp, HAS_REFCOUNT, IS_WASM
assert_array_max_ulp, HAS_REFCOUNT, IS_WASM
)
from numpy._core._rational_tests import rational
from numpy import ma
Expand Down
8 changes: 0 additions & 8 deletions numpy/_core/tests/test_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,6 @@ def test_wrong_arguments(self):
with pytest.raises(TypeError, match="kwargs must be a dict"):
a.__array_function__(np.reshape, (np.ndarray,), (a,), (2, 1))

def test_wrong_arguments(self):
# Check our implementation guards against wrong arguments.
a = np.array([1, 2])
with pytest.raises(TypeError, match="args must be a tuple"):
a.__array_function__(np.reshape, (np.ndarray,), a, (2, 1))
with pytest.raises(TypeError, match="kwargs must be a dict"):
a.__array_function__(np.reshape, (np.ndarray,), (a,), (2, 1))


class TestArrayFunctionDispatch:

Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/tests/test_scalar_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy as np

from numpy._core import sctypes
from numpy.testing import assert_equal, assert_raises, IS_MUSL
from numpy.testing import assert_equal, assert_raises


class TestAsIntegerRatio:
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/tests/test_scalarmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from numpy.testing import (
assert_, assert_equal, assert_raises, assert_almost_equal,
assert_array_equal, IS_PYPY, suppress_warnings, _gen_alignment_data,
assert_warns, check_support_sve,
check_support_sve,
)

types = [np.bool, np.byte, np.ubyte, np.short, np.ushort, np.intc, np.uintc,
Expand Down
5 changes: 1 addition & 4 deletions numpy/_core/tests/test_scalarprint.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
""" Test printing of scalar types.

"""
import code
import platform
import pytest
import sys

from tempfile import TemporaryFile
import numpy as np
from numpy.testing import (
assert_, assert_equal, assert_raises, assert_raises_regex, IS_MUSL)
assert_, assert_equal, assert_raises, IS_MUSL)

class TestRealScalars:
def test_str(self):
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/tests/test_shape_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
_block_concatenate, _block_slicing)
from numpy.testing import (
assert_, assert_raises, assert_array_equal, assert_equal,
assert_raises_regex, assert_warns, IS_PYPY
assert_raises_regex, IS_PYPY
)


Expand Down
10 changes: 3 additions & 7 deletions numpy/_core/tests/test_ufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ def test_signature_dtype_type(self):
np.add(3, 4, signature=(float_dtype, float_dtype, None))

@pytest.mark.parametrize("get_kwarg", [
lambda dt: {"dtype": dt},
lambda dt: {"signature": (dt, None, None)}])
param(lambda dt: {"dtype": dt}, id="dtype"),
param(lambda dt: {"signature": (dt, None, None)}, id="signature")])
def test_signature_dtype_instances_allowed(self, get_kwarg):
# We allow certain dtype instances when there is a clear singleton
# and the given one is equivalent; mainly for backcompat.
Expand All @@ -495,13 +495,9 @@ def test_signature_dtype_instances_allowed(self, get_kwarg):
assert int64 is not int64_2

assert np.add(1, 2, **get_kwarg(int64_2)).dtype == int64
td = np.timedelta(2, "s")
td = np.timedelta64(2, "s")
assert np.add(td, td, **get_kwarg("m8")).dtype == "m8[s]"

@pytest.mark.parametrize("get_kwarg", [
param(lambda x: {"dtype": x}, id="dtype"),
param(lambda x: {"signature": (x, None, None)}, id="signature")])
def test_signature_dtype_instances_allowed(self, get_kwarg):
msg = "The `dtype` and `signature` arguments to ufuncs"

with pytest.raises(TypeError, match=msg):
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/umath.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import numpy
from . import _multiarray_umath
from ._multiarray_umath import * # noqa: F403
from ._multiarray_umath import *
# These imports are needed for backward compatibility,
# do not change them. issue gh-11862
# _ones_like is semi-public, on purpose not added to __all__
Expand Down
2 changes: 1 addition & 1 deletion numpy/_distributor_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"""

try:
from . import _distributor_init_local
from . import _distributor_init_local # noqa: F401
except ImportError:
pass
4 changes: 2 additions & 2 deletions numpy/_pyinstaller/hook-numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
https://pyinstaller.readthedocs.io/en/stable/hooks.html

"""
from PyInstaller.compat import is_conda, is_pure_conda
from PyInstaller.utils.hooks import collect_dynamic_libs, is_module_satisfies
from PyInstaller.compat import is_pure_conda
from PyInstaller.utils.hooks import collect_dynamic_libs

# Collect all DLLs inside numpy's installation folder, dump them into built
# app's root.
Expand Down
Loading
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/numpy/numpy/pull/27309/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy