terrapower / armi

An open-source nuclear reactor analysis automation framework that helps design teams increase efficiency and quality
https://terrapower.github.io/armi/
Apache License 2.0
224 stars 87 forks source link

Enforcing a maximum line length of 120 #1646

Closed john-science closed 6 months ago

john-science commented 7 months ago

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

albeanth commented 7 months ago

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?

john-science commented 7 months ago

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.

opotowsky commented 6 months ago

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).