Skip to content

Commit 41379c6

Browse files
committed
🚨 fix ruff ERA001 errors in the numpy-stubs tests
1 parent a0f9914 commit 41379c6

File tree

10 files changed

+19
-20
lines changed

10 files changed

+19
-20
lines changed

‎src/numpy-stubs/@test/runtime/legacy/ufuncs.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
np.sin(1, out=np.empty(1))
88
np.matmul(np.ones((2, 2, 2)), np.ones((2, 2, 2)), axes=[(0, 1), (0, 1), (0, 1)])
99
np.sin(1, signature="D->D")
10-
# NOTE: `np.generic` subclasses are not guaranteed to support addition;
11-
# re-enable this we can infer the exact return type of `np.sin(...)`.
12-
#
13-
# np.sin(1) + np.sin(1)
10+
11+
np.sin(1) + np.sin(1)
1412
np.sin.types[0]
1513
np.sin.__name__
1614
np.sin.__doc__

‎src/numpy-stubs/@test/runtime/test_ctype_assumptions.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def test_longlong_64(char: str) -> None:
3030
("long", "int32" if WIN32 else f"int{SIZE_P}"),
3131
("intp", f"int{SIZE_P}"),
3232
],
33-
# ids="{} is {}".format,
3433
)
3534
def test_alias_integer(name_c: str, name_expect: str) -> None:
3635
signed_c: type[np.signedinteger] = getattr(np, name_c)
@@ -50,7 +49,6 @@ def test_alias_integer(name_c: str, name_expect: str) -> None:
5049
("double", "float64"),
5150
("longdouble", "float96" if WIN32 else f"float{SIZE_P + 64}"),
5251
],
53-
# ids="{} is {}".format,
5452
)
5553
def test_alias_floating(name_c: str, name_expect: str) -> None:
5654
floating_c: type[np.floating] = getattr(np, name_c)

‎src/numpy-stubs/@test/static/accept/constants.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ assert_type(np.inf, float)
88
assert_type(np.nan, float)
99
assert_type(np.pi, float)
1010

11-
# assert_type(np.little_endian, bool)
11+
assert_type(np.little_endian, bool)
1212

1313
assert_type(np.True_, np.bool[Literal[True]])
1414
assert_type(np.False_, np.bool[Literal[False]])

‎src/numpy-stubs/@test/static/accept/polynomial_polybase.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ assert_type(PS_all.has_samewindow(PS_all), bool)
9090
assert_type(PS_all.has_sametype(PS_all), bool)
9191
assert_type(PS_poly.has_sametype(PS_poly), bool)
9292
assert_type(PS_poly.has_sametype(PS_leg), bool)
93-
# different outcomes between mypy and pyright
94-
# assert_type(PS_poly.has_sametype(NotADirectoryError), L[False])
93+
assert_type(PS_poly.has_sametype(NotADirectoryError), bool)
9594

9695
assert_type(PS_poly.copy(), npp.Polynomial)
9796
assert_type(PS_cheb.copy(), npp.Chebyshev)

‎src/numpy-stubs/@test/static/accept/polynomial_series.pyi

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ assert_type(npp.polynomial.polyfromroots(AR_f8), _Float64_1d)
3232
assert_type(npp.polynomial.polyfromroots(AR_c16), _Complex128_1d)
3333
assert_type(npp.polynomial.polyfromroots(AR_O), _Object_1d)
3434

35-
# assert_type(npp.polynomial.polyadd(AR_b, AR_b), NoReturn)
3635
assert_type(npp.polynomial.polyadd(AR_u4, AR_b), _Float64_1d)
3736
assert_type(npp.polynomial.polyadd(AR_i8, AR_i8), _Float64_1d)
3837
assert_type(npp.polynomial.polyadd(AR_f8, AR_i8), _Float64_1d)
@@ -51,12 +50,10 @@ assert_type(npp.polynomial.polypow(AR_f8, 2), _Float64_1d)
5150
assert_type(npp.polynomial.polypow(AR_c16, 2), _Complex128_1d)
5251
assert_type(npp.polynomial.polypow(AR_O, 2), _Object_1d)
5352

54-
# assert_type(npp.polynomial.polyder(PS_poly), _Object_nd)
5553
assert_type(npp.polynomial.polyder(AR_f8), _Float64_nd)
5654
assert_type(npp.polynomial.polyder(AR_c16), _Complex128_nd)
5755
assert_type(npp.polynomial.polyder(AR_O, m=2), _Object_nd)
5856

59-
# assert_type(npp.polynomial.polyint(PS_poly), _Object_nd)
6057
assert_type(npp.polynomial.polyint(AR_f8), _Float64_nd)
6158
assert_type(npp.polynomial.polyint(AR_f8, k=AR_c16), _ComplexFloating_nd)
6259
assert_type(npp.polynomial.polyint(AR_O, m=2), _Object_nd)

‎src/numpy-stubs/@test/static/accept/scalars.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ assert_type(complex(O), complex)
164164
# According to the typing spec, the following statements are valid, see
165165
# https://typing.readthedocs.io/en/latest/spec/constructors.html#new-method
166166

167+
# ruff: noqa: ERA001
168+
167169
# assert_type(np.object_(), None)
168170
# assert_type(np.object_(None), None)
169171
# assert_type(np.object_(array_nd), np.ndarray[Any, np.dtype[np.object_]])

‎src/numpy-stubs/@test/static/accept/strings.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ assert_type(np.strings.less(AR_S, AR_S), _BoolArray)
4242
assert_type(np.strings.less(AR_T, AR_T), _BoolArray)
4343
assert_type(np.strings.less(AR_S, AR_U, dtype=np.bool_), _BoolArray)
4444

45-
# TODO(jorenham)
46-
# https://github.com/numpy/numtype/issues/230
45+
# TODO(jorenham): https://github.com/numpy/numtype/issues/230
46+
# ruff: noqa: ERA001
4747
# assert_type(np.strings.add(AR_U, AR_U), _StrArray)
4848
# assert_type(np.strings.add(AR_S, AR_S), _BytesArray)
4949
# assert_type(np.strings.add(AR_T, AR_T), _nt.StringArray)

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,6 @@ assert_type(np.testing.HAS_LAPACK64, bool)
7777
assert_type(np.testing.assert_(1, msg="test"), None)
7878
assert_type(np.testing.assert_(2, msg=lambda: "test"), None)
7979

80-
# cannot be tested on pyright
81-
# if sys.platform == "win32" or sys.platform == "cygwin":
82-
# assert_type(np.testing.memusage(), int)
83-
# elif sys.platform == "linux":
84-
# assert_type(np.testing.memusage(), int | None)
85-
8680
assert_type(np.testing.jiffies(), int)
8781

8882
assert_type(np.testing.build_err_msg([0, 1, 2], "test"), str)
@@ -190,3 +184,11 @@ assert_type(np.testing.assert_no_gc_cycles(), contextlib._GeneratorContextManage
190184
assert_type(np.testing.assert_no_gc_cycles(func3, 5), None)
191185

192186
assert_type(np.testing.break_cycles(), None)
187+
188+
# NOTE: Platform-dependent behavior cannot be tested on pyright
189+
# ruff: noqa: ERA001
190+
191+
# if sys.platform == "win32" or sys.platform == "cygwin":
192+
# assert_type(np.testing.memusage(), int)
193+
# elif sys.platform == "linux":
194+
# assert_type(np.testing.memusage(), int | None)

‎src/numpy-stubs/@test/static/reject/char.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ AR_U: _nt.Array[np.str_]
55
AR_S: _nt.Array[np.bytes_]
66

77
# TODO(jorenham)
8+
# ruff: noqa: ERA001
9+
810
# np.char.equal(AR_U, AR_S)
911
# np.char.not_equal(AR_U, AR_S)
1012
# np.char.greater_equal(AR_U, AR_S)

‎src/numpy-stubs/@test/static/reject/strings.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ AR_U: _nt.Array[np.str_]
55
AR_S: _nt.Array[np.bytes_]
66

77
# TODO(jorenham)
8+
# ruff: noqa: ERA001
89

910
# np.strings.equal(AR_U, AR_S)
1011
# np.strings.not_equal(AR_U, AR_S)

0 commit comments

Comments
 (0)