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

Enforcing a maximum line length of 120 #1646

Merged
merged 29 commits into from
Apr 5, 2024
Merged

Enforcing a maximum line length of 120 #1646

merged 29 commits into from
Apr 5, 2024

Conversation

john-science
Copy link
Member

What is the change?

Using ruff to enforce a maximum line length of 120. Because ruff is doing the enforcing, GitHub CI will catch and enforce this new rule in the future.

This was mostly an automated process, though I did have to touch the pyproject.toml by hand, and I touched the release notes.

Why is the change being made?

This is purely for code quality and readability; lines that are longer than 120 characters are pretty hard to read on a git diff or even the "GitHub Diff" UI in PRs. They also add to a lot of clutter and confusion in most IDEs.

We could also move the bar to 100 characters, which would be more standard. But... ruff tells me that would make changes to 768 files, and that feels like too big a pill to swallow.


Checklist

  • The release notes (location doc/release/0.X.rst) are up-to-date with any important changes.
  • The documentation is still up-to-date in the doc folder.
  • If any requirements were affected, mention it in the release notes.
  • The dependencies are still up-to-date in pyproject.toml.

@john-science john-science added documentation Improvements or additions to documentation cleanup Code/comment cleanup: Low Priority labels Feb 7, 2024
Copy link
Member

@albeanth albeanth left a comment

Choose a reason for hiding this comment

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

I reviewed the first half of the files changed. @opotowsky is doing the second half.

armi/bookkeeping/report/html.py Outdated Show resolved Hide resolved
armi/materials/inconelX750.py Outdated Show resolved Hide resolved
armi/materials/tZM.py Outdated Show resolved Hide resolved
armi/nuclearDataIO/cccc/dlayxs.py Outdated Show resolved Hide resolved
armi/materials/material.py Outdated Show resolved Hide resolved
Copy link
Member

@opotowsky opotowsky left a comment

Choose a reason for hiding this comment

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

There are a ton of updates in here that increase line length. Can you undo all those changes? That creates more unnecessary work for us (it gets reviewed in this PR, then again in the 100 char line length limit PR).

@albeanth
Copy link
Member

albeanth commented Feb 7, 2024

There are a ton of updates in here that increase line length. Can you undo all those changes? That creates more unnecessary work for us (it gets reviewed in this PR, then again in the 100 char line length limit PR).

This is true if the plan is to move the line length bar again. Which I don't really understand a motivation for. I can get trimming it to 120, but 100? Or 88? It seems unnecessary?

Co-authored-by: Tony Alberti <aalberti@terrapower.com>
@john-science john-science marked this pull request as draft February 7, 2024 21:30
@john-science
Copy link
Member Author

This is true if the plan is to move the line length bar again. Which I don't really understand a motivation for. I can get trimming it to 120, but 100? Or 88? It seems unnecessary?

Well, two weeks ago, we had lines that were >200 characters long. That is a bit too much, even for me.

I tend to work at 120. Though... 88 is by a WIDE margin the most common. For instance, that is the default in both black and ruff.

To be clear, I wasn't really interested in lowering the bar again. But I am by FAR in the minority here. I just happen to find that scientific code has long lines of math that mean stringent line-length limits make code harder to read and parse. Perhaps the "88 character limit" comes from website development and other work of that sort, where no individual line has a LOT of math to it.

@john-science john-science marked this pull request as ready for review February 7, 2024 23:03
Copy link
Member

@opotowsky opotowsky left a comment

Choose a reason for hiding this comment

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

I reviewed the bottom 26 files.

I originally commented that lines already adjusted to a 100 char limit shouldn't be increased to 120. But we discussed that and since we aren't probably ever going to enforce a 100 char line length, I was OK leaving those edits as-is.

I now noticed a bunch of places where a 120 char line was edited down to a 100 char line. I commented on it in one file, but once I saw how pervasive the inconsistency was I stopped commenting. It's not the biggest deal....after all, these lines technically follow the <120 rule. But how this got inconsistently applied is baffling to me. Is it ruff misbehaving? Your error?

armi/reactor/parameters/parameterDefinitions.py Outdated Show resolved Hide resolved
armi/reactor/converters/tests/test_geometryConverters.py Outdated Show resolved Hide resolved
armi/reactor/blueprints/reactorBlueprint.py Show resolved Hide resolved
armi/reactor/blueprints/reactorBlueprint.py Outdated Show resolved Hide resolved
armi/reactor/blueprints/gridBlueprint.py Outdated Show resolved Hide resolved
armi/reactor/blueprints/gridBlueprint.py Outdated Show resolved Hide resolved
armi/reactor/blocks.py Outdated Show resolved Hide resolved
armi/reactor/blockParameters.py Show resolved Hide resolved
@@ -33,8 +33,8 @@ def getBlockParameterDefinitions():
"orientation",
units=units.DEGREES,
description=(
"Triple representing rotations counterclockwise around each spatial axis. For example, "
"a hex assembly rotated by 1/6th has orientation (0,0,60.0)"
"Triple representing rotations counterclockwise around each spatial axis. For "
Copy link
Member

Choose a reason for hiding this comment

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

same as below....seems like some line wraps get 100 chars applied and some get 120

Comment on lines +165 to +166
"Duration that a block has been in the core multiplied by the fraction "
"of full power generated in that time."
Copy link
Member

Choose a reason for hiding this comment

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

same comment as below

Copy link
Member

@albeanth albeanth left a comment

Choose a reason for hiding this comment

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

The first 26 files are good.

Co-authored-by: Arrielle Opotowsky <c-aopotowsky@terrapower.com>
@john-science john-science requested a review from albeanth March 18, 2024 16:13
Copy link
Member

@albeanth albeanth left a comment

Choose a reason for hiding this comment

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

I still approve the first 26 files. @opotowsky to approve the second half.

@opotowsky
Copy link
Member

I can approve this once my review is responded to.

Looks like I have an outstanding british v american english spelling thing, and question for my review. John partially answered my questions about the 100 vs 120 char issue, but it seems the inconsistency is broader than the question that was answered (that related to impl tags).

john-science and others added 2 commits March 19, 2024 15:39
@john-science john-science merged commit 45ef386 into main Apr 5, 2024
21 checks passed
@john-science john-science deleted the line_length_120 branch April 5, 2024 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code/comment cleanup: Low Priority documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants