Skip to content

fixing e501 for tests/commands#2688

Merged
freakboy3742 merged 12 commits intobeeware:mainfrom
JohananOppongAmoateng:e501-tests
Mar 5, 2026
Merged

fixing e501 for tests/commands#2688
freakboy3742 merged 12 commits intobeeware:mainfrom
JohananOppongAmoateng:e501-tests

Conversation

@JohananOppongAmoateng
Copy link
Contributor

@JohananOppongAmoateng JohananOppongAmoateng commented Feb 16, 2026

This pr is a continuation of fixes for the e501 issues in #2383

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@JohananOppongAmoateng JohananOppongAmoateng marked this pull request as ready for review February 16, 2026 13:34
Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

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

Thanks for those updates - looks like more good progress towards clean Ruff output.

I've flagged a few places where the formatting is valid, but needs an update to be consistent with our internal style. I've also flagged a couple of places where the style choices are a bit odd. If those places are the result of automated update from Ruff, then we'll live with the output of that tool - but if they're manually applied choices, in most cases, the older syntax is preferred.

Comment on lines +135 to +136
"\n stderr: '\nfatal: could not clone repository"
" 'https://example.com' \n'",
Copy link
Member

Choose a reason for hiding this comment

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

As noted in the past PR - when we've got a string as one argument of many, it's preferable to use bracket notation to highlight that this is one string argument, not two:

Suggested change
"\n stderr: '\nfatal: could not clone repository"
" 'https://example.com' \n'",
(
"\n stderr: '\nfatal: could not clone repository"
" 'https://example.com' \n'"
),

Comment on lines +141 to +145
"\n stderr: '\nfatal: Could not read from remote repository.\n\nPlease"
" make sure you have the correct access rights\nand the repository"
" exists. \n'",
"Could not read from remote repository.\n\nPlease make sure "
"you have the correct access rights\nand the repository exists.",
Copy link
Member

Choose a reason for hiding this comment

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

As above - these two should be bracket-wrapped

Comment on lines +149 to +152
"\n stderr: '\nfatal: unable to access 'https://example.com/': "
"OpenSSL/3.2.2: error:0A000438:SSL routines::tlsv1 alert internal error'",
"Unable to access 'https://example.com/': OpenSSL/3.2.2: "
"error:0A000438:SSL routines::tlsv1 alert internal error.",
Copy link
Member

Choose a reason for hiding this comment

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

As above - these two should be bracket-wrapped

Comment on lines +52 to +53
f"The directory {bundle_path.relative_to(base_path)} already exists; overwrite"
" [y/N]? "
Copy link
Member

Choose a reason for hiding this comment

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

Examples like this one are a bit of a judgement call as to whether extra parentheses are needed, as it's a list with one item; I'd be inclined to they should, to reinforce that it's a single prompt in a list.

(Similarly for the 2 other equivalent changes in this file)

Comment on lines +267 to +268
filename=tmp_path
/ "data/stub/986428ef9d5a1852fc15d4367f19aa328ad530686056e9d83cdde03407c0bceb/My-Stub.zip",
/ "data/stub/986428ef9d5a1852fc15d4367f19aa328ad530686056e9d83cdde03407c0bceb/My-Stub.zip", # 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.

Preference here would be (a) to use brackets to clarify the scope of the filename argument, and (b) to break the string in more places to avoid the need for the noqa. Github won't let me code suggest here, but something like:

        filename=(
            tmp_path
            / "data/stub"
            / "986428ef9d5a1852fc15d4367f19aa328ad530686056e9d83cdde03407c0bceb"
            / "My-Stub.zip"
        ),

assert capsys.readouterr().out == (
"\n"
assert (
capsys.readouterr().out == "\n"
Copy link
Member

Choose a reason for hiding this comment

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

This is an odd change - the brackets are the exact opposite of what I would have expected. The reasoning is the same as for other bracket usage - it's not intuitive to tell which statements are the start of a string, and which the start of a new argument. The previous formatting made this clear - copses.readouterr().out = (...some multiline string...); the new formatting is ambiguous.


def test_test_dependencies_without_requires():
"If the global config doesn't specify test requirements, test dependencies are used as is"
"""If the global config doesn't specify test requirements, test " "dependencies are
Copy link
Member

Choose a reason for hiding this comment

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

A stray pair of quotes, probably from a line break that existed at one point:

Suggested change
"""If the global config doesn't specify test requirements, test " "dependencies are
"""If the global config doesn't specify test requirements, test dependencies are

(
"There is nothing wrong with your television set.\n"
"Do not attempt to adjust the picture."
),
Copy link
Member

Choose a reason for hiding this comment

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

+1 to this change - this is the preferred format for multi-line strings.

"Wait message... started\nWait message... finished\n"
assert (
capsys.readouterr().out == "Wait message... started\nWait message... finished\n"
)
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit of a value judgement - if an automated tool is doing this, then fine; but otherwise the older format would be preferred.

"... still waiting\n... still waiting\n... still waiting\n"
assert (
capsys.readouterr().out
== "... still waiting\n... still waiting\n... still waiting\n"
Copy link
Member

Choose a reason for hiding this comment

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

Again - the older format would be preferred unless this is a tool automated change.

@freakboy3742
Copy link
Member

As a procedural thing - can I ask that you don't mark conversations as resolved (or, rather, that you only mark a conversation as resolved if your the person who started the conversation). When I (or another reviewer) provides a comment, that usually means we intend to review later work and ensure that the issues that were found have been resolved - that is when the conversation is resolved. Otherwise, the reviewer loses the context that they asked for a change, and it's not necessarily clear if the way you've responded to the comment was what was the reviewer intended.

Otherwise, it looks like we're 1 pre-commit violation statement away from this being reviewable. If you make that fix, I'll take another pass at it.

@JohananOppongAmoateng
Copy link
Contributor Author

As a procedural thing - can I ask that you don't mark conversations as resolved (or, rather, that you only mark a conversation as resolved if your the person who started the conversation). When I (or another reviewer) provides a comment, that usually means we intend to review later work and ensure that the issues that were found have been resolved - that is when the conversation is resolved. Otherwise, the reviewer loses the context that they asked for a change, and it's not necessarily clear if the way you've responded to the comment was what was the reviewer intended.

Otherwise, it looks like we're 1 pre-commit violation statement away from this being reviewable. If you make that fix, I'll take another pass at it.

okay thanks for letting me know

@JohananOppongAmoateng
Copy link
Contributor Author

JohananOppongAmoateng commented Mar 4, 2026

@freakboy3742 @kattni sorry this pr has really been slow i have to work on some other stuff since last week hoping i can free up sometime this week and get this over the finish line

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

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

Thanks for those updates. I've pushed a couple of final cleanups; the main issue is around when to use brackets on a multi-line string.

To be clear about the problem I'm referring to: the issue we're trying to avoid is the following:

    some_function(
        "this is a long string"
        "that continues onto multiple lines",
        "but this is a *second* argument, not a third",
    )

This is 100% legal Python, but it's not clear that the first two lines are actually one argument. By adding braces:

    some_function(
        (
            "this is a long string"
            "that continues onto multiple lines"
        ),
        "but this is a *second* argument, not a third",
    )

there's at least a visual cue that the first two string segments are a single argument.

They're both completely legal Python; the preference for the second is purely a code readability thing. Unfortunately, I'm not aware of any way to enforce that rule systematically; and this PR had a number of cases where the "preferred" syntax was reverted.

That's a relatively minor set of changes, though - the rest of your work on this PR is great.

),
pytest.param(
"\n stderr: 'Mysterious git clone edge case with no fatal error.",
("\n stderr: 'Mysterious git clone edge case with no fatal error."),
Copy link
Member

Choose a reason for hiding this comment

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

The brackets are redundant here.

Suggested change
("\n stderr: 'Mysterious git clone edge case with no fatal error."),
"\n stderr: 'Mysterious git clone edge case with no fatal error.",

Comment on lines +159 to +160
"Unable to access 'https://example.com/': OpenSSL/3.2.2: "
"error:0A000438:SSL routines::tlsv1 alert internal error.",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"Unable to access 'https://example.com/': OpenSSL/3.2.2: "
"error:0A000438:SSL routines::tlsv1 alert internal error.",
(
"Unable to access 'https://example.com/': OpenSSL/3.2.2: "
"error:0A000438:SSL routines::tlsv1 alert internal error."
),

Comment on lines +149 to +150
"Could not read from remote repository.\n\nPlease make sure "
"you have the correct access rights\nand the repository exists.",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"Could not read from remote repository.\n\nPlease make sure "
"you have the correct access rights\nand the repository exists.",
(
"Could not read from remote repository.\n\nPlease make sure "
"you have the correct access rights\nand the repository exists."
),

Comment on lines +52 to +56
(
f"The directory {bundle_path.relative_to(base_path)} already exists;"
" overwrite"
" [y/N]? "
),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
(
f"The directory {bundle_path.relative_to(base_path)} already exists;"
" overwrite"
" [y/N]? "
),
(
f"The directory {bundle_path.relative_to(base_path)} already exists;"
" overwrite [y/N]? "
),

Comment on lines +94 to +95
" overwrite"
" [y/N]? "
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
" overwrite"
" [y/N]? "
" overwrite [y/N]? "

Comment on lines +126 to +127
" overwrite"
" [y/N]? "
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
" overwrite"
" [y/N]? "
" overwrite [y/N]? "

@freakboy3742 freakboy3742 merged commit 7853cea into beeware:main Mar 5, 2026
60 checks passed
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