-
-
Notifications
You must be signed in to change notification settings - Fork 48
ruff: 0.12.10 fixes #892
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
Merged
Merged
ruff: 0.12.10 fixes #892
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,26 +53,38 @@ def test_ruff_works( | |
| expected_path_2 = os.path.join("tests", "data", "notebook_starting_with_md.ipynb") | ||
|
|
||
| out, err = capsys.readouterr() | ||
|
|
||
| # ignore ruff's suggestions | ||
| out = "\n".join([x for x in out.splitlines() if "cell_" in x]) | ||
| prev = "" | ||
| output: list[str] = [] | ||
| for line in out.splitlines(): | ||
| if "cell_" in line: | ||
| # append previous line and matching line | ||
| output.append(prev) | ||
| output.append(line) | ||
| prev = line | ||
|
|
||
| expected_out = ( | ||
| f"{expected_path_1}:cell_1:1:8: F401 [*] `os` imported but unused\n" | ||
| f"{expected_path_1}:cell_1:3:8: F401 [*] `glob` imported but unused\n" | ||
| f"{expected_path_1}:cell_1:5:8: F401 [*] `nbqa` imported but unused\n" | ||
| f"{expected_path_0}:cell_1:1:8: F401 [*] `os` imported but unused\n" | ||
| f"{expected_path_0}:cell_1:3:8: F401 [*] `glob` imported but unused\n" | ||
| f"{expected_path_0}:cell_1:5:8: F401 [*] `nbqa` imported but unused\n" | ||
| f"{expected_path_0}:cell_4:1:1: E402 Module level import not at top of file\n" | ||
| f"{expected_path_0}:cell_4:1:20: F401 [*] `random.randint` imported but unused\n" | ||
| f"{expected_path_0}:cell_5:1:1: E402 Module level import not at top of file\n" | ||
| f"{expected_path_0}:cell_5:2:1: E402 Module level import not at top of file\n" | ||
| f"{expected_path_2}:cell_1:1:8: F401 [*] `os` imported but unused\n" | ||
| f"{expected_path_2}:cell_1:3:8: F401 [*] `glob` imported but unused\n" | ||
| f"{expected_path_2}:cell_1:5:8: F401 [*] `nbqa` imported but unused\n" | ||
| ) | ||
| assert "\n".join(sorted(out.replace("\r\n", "\n").splitlines())) == "\n".join( | ||
| sorted(expected_out.splitlines()) | ||
| f"F401 [*] `os` imported but unused\n --> {expected_path_1}:cell_1:1:8\n" | ||
| f"F401 [*] `glob` imported but unused\n --> {expected_path_1}:cell_1:3:8\n" | ||
| f"F401 [*] `nbqa` imported but unused\n --> {expected_path_1}:cell_1:5:8\n" | ||
| f"F401 [*] `os` imported but unused\n --> {expected_path_0}:cell_1:1:8\n" | ||
| f"F401 [*] `glob` imported but unused\n --> {expected_path_0}:cell_1:3:8\n" | ||
| f"F401 [*] `nbqa` imported but unused\n --> {expected_path_0}:cell_1:5:8\n" | ||
| f"E402 Module level import not at top of file\n --> {expected_path_0}:cell_4:1:1\n" | ||
| f"F401 [*] `random.randint` imported but unused\n --> {expected_path_0}:cell_4:1:20\n" | ||
| f"E402 Module level import not at top of file\n --> {expected_path_0}:cell_5:1:1\n" | ||
| f"E402 Module level import not at top of file\n --> {expected_path_0}:cell_5:2:1\n" | ||
| f"F401 [*] `os` imported but unused\n --> {expected_path_2}:cell_1:1:8\n" | ||
| f"F401 [*] `glob` imported but unused\n --> {expected_path_2}:cell_1:3:8\n" | ||
| f"F401 [*] `nbqa` imported but unused\n --> {expected_path_2}:cell_1:5:8\n" | ||
| ) | ||
|
|
||
| # simple dedent of '\s+-->' | ||
| out = "\n".join(sorted([x.lstrip() for x in output])) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so I am doing
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, my fix for the above issue is here. |
||
| exp = "\n".join(sorted([x.lstrip() for x in expected_out.splitlines()])) | ||
|
|
||
| assert out == exp | ||
| assert err == "" | ||
|
|
||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit confused what's required here.
I tried
rf"(?<=\s+--> {re.escape(relative_path)}:)\d+"but it fails because re.PatternError: look-behind requires fixed-width pattern. so\s+is not allowed.I saw both
_-->and__-->in the ruff tests.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for your fix
I'm not sure what you mean here, sorry - did you figure out a fix?