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

Improve code style for strings #40

Merged
merged 3 commits into from
Aug 3, 2023
Merged

Conversation

EliahKagan
Copy link
Collaborator

@EliahKagan EliahKagan commented Aug 2, 2023

This makes three kinds of style fixes/changes, of which the first two are the most valuable but the third is the only one that really requires explanation.

  • A number of f-strings performed no string interpolation. This changes them to be regular string literals.

  • One of the docstrings had a very wide doctest. This was code originally in a main() function that became unwrapped when converted to a docstest. (Originally it was wrapped black-style.) This rewraps it as it had been, using the "..." statement continuation syntax for doctests.

  • In original_codebase/, I wrapped docstrings to 88 columns (the black default, which black does not enforce in docstrings, but which the new docstrings are consistent with). I think it makes sense to do this, because it is in line with the kind of stylistic changes to the original codebase that were done recently in bf86554 (part of V0.0.1 packaging #30).

    To do that, I kept everything under 89 columns unchanged, even when wrapping other parts of the same docstring. I wrapped overly long parts to 79 columns, which seemed to look better than wrapping to 88. I maintained the existing style of using hanging indents to continue descriptions of individual function parameters. In one case I departed from this, instead removing some extra words from parameter descriptions ("if you want to" became "to").

The changes to the original codebase are the least important, because that is not actively developed. If those changes are not considered worthwhile, I'd be pleased to remove them from this PR. One of my motivations in including them is that if we add more automatic style checking in the future, docstrings in the original codebase will no longer prevent it from being used on the entire repository if desired (as black and isort are being used).

This changes f-strings in which no string interpolation is (or is
intended) to occur into regular strings.
@EliahKagan EliahKagan changed the title Fix f-strings without placeholders Improve code style for strings Aug 2, 2023
A docstring was very wide, due to a doctest containing a statement
that was originally split across several lines, but when moved into
the docstring was unwrapped.

This wraps it using the "..." line contination syntax for doctests.
Code style in the original codebase, including wrapping function
definitions and calls and regrouping/reordering imports, was
reglarized in bf86554 (as part of bazingagin#30). But line lengths in
docstrings were not changed (because black does not automate this
and it is unrelated to isort).

This tweaks docstrings in modules in original_codebase/ so they're
at most 89 columns. In one case, I removed a small amount of extra
wording from a docstring's description of function parameters. In
all other cases, I wrapped parts of docstrings that were over 89
columns to 79 columns, while leaving other parts (even in the same
docstrings and between 79 and 89 columns) as they were before. When
wrapping descriptions of function parameters, I used hanging
indents, for readability and because that style is the most
consistent with nearby code (and code outside original_codebase/).
@EliahKagan EliahKagan marked this pull request as ready for review August 2, 2023 04:00
@bazingagin bazingagin merged commit 6558e07 into bazingagin:main Aug 3, 2023
@EliahKagan EliahKagan deleted the strings branch August 3, 2023 22:01
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