Skip to content

MAINT: Enforce ruff E501 #29068

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 4 commits into from
May 29, 2025
Merged

MAINT: Enforce ruff E501 #29068

merged 4 commits into from
May 29, 2025

Conversation

eendebakpt
Copy link
Contributor

See #28947

@@ -384,9 +384,6 @@
('z', 'u1')]

NbufferT = [
# x Info color info y z
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: same information is in the array Ndescr above

@@ -554,18 +554,18 @@ def test_outlier(self):
assert_equal(len(a), numbins)

def test_scott_vs_stone(self):
"""Verify that Scott's rule and Stone's rule converges for normally distributed data"""
"""Verify that Scott's rule and Stone's rule converges for normally distributed data""" # noqa: E501

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could turn this into a # comment over two lines.

@@ -55,7 +55,7 @@ def dtype(self) -> _DTypeT_co: ...


# A subset of `npt.DTypeLike` that can be parametrized w.r.t. `np.generic`
_DTypeLike: TypeAlias = type[_ScalarT] | np.dtype[_ScalarT] | _SupportsDType[np.dtype[_ScalarT]]
_DTypeLike: TypeAlias = type[_ScalarT] | np.dtype[_ScalarT] | _SupportsDType[np.dtype[_ScalarT]] # noqa: E501

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be inclined to skip _typing, it is its own world.

@@ -1352,7 +1352,7 @@ def test_boolean_indexing_fast_path(self):
"size of axis is 3 but size of corresponding boolean axis is 1",
lambda: a[idx1])

# This used to incorrectly give a ValueError: operands could not be broadcast together
# This used to incorrectly give a ValueError: operands could not be broadcast together # noqa: E501
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make this a two line comment.

@jorenham
Copy link
Member

jorenham commented May 27, 2025

I agree with @charris: We follow the python typing spec, which in its stub style guide says:

Stub files should be limited to 130 characters per line.

But this isn't possible to configure in ruff yet, see astral-sh/ruff#16057 and astral-sh/ruff#7696.

And even though numpy/_typing/_dtype_like.py is not a .pyi stub, it has all the characteristics of one, and might even become one in the near future.

@@ -166,7 +166,7 @@ def check_may_share_memory_exact(a, b):
err_msg = ""
if got != exact:
err_msg = " " + "\n ".join([
f"base_a - base_b = {a.__array_interface__['data'][0] - b.__array_interface__['data'][0]!r}",
f"base_a - base_b = {a.__array_interface__['data'][0] - b.__array_interface__['data'][0]!r}", # noqa: E501
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd break out the computation on a separate line. Putting a lot of computation into a { ... } is hard to read.

@@ -402,7 +402,7 @@ def check(A, U, exists=None):
exists = (X is not None)

if X is not None:
assert_(sum(a * x for a, x in zip(A, X)) == sum(a * u // 2 for a, u in zip(A, U)))
assert_(sum(a * x for a, x in zip(A, X)) == sum(a * u // 2 for a, u in zip(A, U))) # noqa: E501
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd break this into two computations before the assert_. Now that we are using pytest, you can also use assert instead of the assert_ function.

@charris charris merged commit 3f1b457 into numpy:main May 29, 2025
74 checks passed
@charris
Copy link
Member

charris commented May 29, 2025

Thanks @eendebakpt .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy