-
Notifications
You must be signed in to change notification settings - Fork 363
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
Add ruff pre-commit hook #1502
Add ruff pre-commit hook #1502
Changes from all commits
0a13d4a
a0d0115
84b2bdd
cd48c84
bc27fb2
d0ceefb
248b968
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -251,7 +251,7 @@ async def _get_file( | |
if isfilelike(lpath): | ||
outfile = lpath | ||
else: | ||
outfile = open(lpath, "wb") | ||
outfile = open(lpath, "wb") # noqa: ASYNC101 | ||
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. What would be the problem here? 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. https://docs.astral.sh/ruff/rules/open-sleep-or-subprocess-in-async-function/ Not sure there is a good way around it without relying the aiofiles dependency though so I just suppressed it 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. What a strange rule! Just about any normal function call blocks for some time, and 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. Yeah, I just left it because it seemed useful and we can noqa the nonsense suggestions like this. 👍 |
||
|
||
try: | ||
chunk = True | ||
|
@@ -279,7 +279,7 @@ async def gen_chunks(): | |
context = nullcontext(lpath) | ||
use_seek = False # might not support seeking | ||
else: | ||
context = open(lpath, "rb") | ||
context = open(lpath, "rb") # noqa: ASYNC101 | ||
use_seek = True | ||
|
||
with context as f: | ||
|
@@ -801,7 +801,7 @@ async def get_range(session, url, start, end, file=None, **kwargs): | |
async with r: | ||
out = await r.read() | ||
if file: | ||
with open(file, "r+b") as f: | ||
with open(file, "r+b") as f: # noqa: ASYNC101 | ||
f.seek(start) | ||
f.write(out) | ||
else: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,6 +123,7 @@ def test_chmod(mount_local): | |
["cp", str(mount_dir / "text"), str(mount_dir / "new")], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
check=False, | ||
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. Why the extra arg 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. https://docs.astral.sh/ruff/rules/subprocess-run-without-check/ Makes you think about whether you should enable to reraise an exception if the process fails (instead of having it fail silently). Happy to disable that if you prefer though. 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. I suppose 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. @martindurant Check=True made the test fail so I am just leaving it as is for now. |
||
) | ||
|
||
assert cp.stderr == b"" | ||
|
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.
So lon we've been told to the the opposite, no?
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.
https://docs.astral.sh/ruff/rules/any-eq-ne-annotation/ Happy to revert this rule too and disable if necessary, just let me know.