Skip to content
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

add black #8

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

add black #8

wants to merge 3 commits into from

Conversation

keewis
Copy link
Collaborator

@keewis keewis commented Nov 21, 2024

As mentioned in #7 (comment), this adds black to the hooks and "blackens" the existing code. Again, feel free to close if the changes are too much of an issue.

(If we do decide to merge, though, I'd like to first add be2151b to the set of commits ignored by git blame to avoid interfering with that)

Copy link
Owner

@mdhaber mdhaber left a comment

Choose a reason for hiding this comment

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

I've marked my main concerns with Black inline. The whitespace and quotation mark fixes are fine; the main concern is line breaks. If it could respect my choice of hanging indents and allow more than one list item per line, I might be convinced. I find it hard to navigate files when lists take up an entire screen like this.

'__or__', '__pow__', '__rshift__', '__sub__', '__truediv__',
'__xor__'] + ['__divmod__', '__floordiv__']
binary_names = [
"__add__",
Copy link
Owner

@mdhaber mdhaber Nov 21, 2024

Choose a reason for hiding this comment

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

This is one of the things I am not a fan of. Perhaps if there is a rule that can be turned off, I can probably live with it.

Comment on lines +453 to +457
out = (
MaskedArray(res, mask)
if name not in output_arrays
else [MaskedArray(resi, maski) for resi, maski in zip(res, mask)]
)
Copy link
Owner

Choose a reason for hiding this comment

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

Similarly here. I preferred the initial formatting of this ternary.

Comment on lines +93 to +96
def iadd(x, y):
x += y


Copy link
Owner

Choose a reason for hiding this comment

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

And these one-liners just don't need four lines, IMO.

Copy link
Collaborator Author

@keewis keewis Nov 21, 2024

Choose a reason for hiding this comment

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

I wonder, would it be fine to just use the functions in operator instead?

(in a separate PR, that doesn't have anything to do with code style)

Copy link
Owner

Choose a reason for hiding this comment

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

Maybe. I think I had a bug with the in-place operators anyway, so I'll investigate.

Copy link
Collaborator Author

@keewis keewis left a comment

Choose a reason for hiding this comment

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

black intentionally doesn't support options, so it's all-or-nothing.

The reasoning for the multi-line lists is that it allows modifications to be a single line diff instead of multiple / the modification of a long line.

For ternary operators I would actually write it like black did: each part of the ternary on a separate line.

I guess code style is a matter of habits and taste (personal preference), and thus often something hard to argue for / against. Again, the big plus of black is consistency rather than following everyone's personal preference perfectly; it is following more of a "mean denominator", if that makes sense.

Comment on lines +93 to +96
def iadd(x, y):
x += y


Copy link
Collaborator Author

@keewis keewis Nov 21, 2024

Choose a reason for hiding this comment

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

I wonder, would it be fine to just use the functions in operator instead?

(in a separate PR, that doesn't have anything to do with code style)

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

Successfully merging this pull request may close these issues.

2 participants