1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-11 08:37:59 +00:00

ci/lint: disable isort checks

The error message is completely incomprehensible and also inconsistent
about whether it wants two newlines or just one after an import.

Consider this python script:

import sys

sys.stdout.write("garbage")

That passes the ruff isort check just fine. But this does not:

import sys

def fake_function():
    sys.stdout.write("garbage")

fake_function()

This will fail. Why? Because there should be two newlines after imports
but only for functions. This is because of PEP8 rules about blank lines,
but this is not explained or referenced anywhere in output from the
lint. You only get a cryptic "Import block is un-sorted or un-formatted"
with some visual that isn't clear in what it's trying to communicate.
Additionally, it seems to go a bit beyond PEP8 and also will fail if you
have too many blank lines (i.e. more than 1) in certain cases if the
succeeding line isn't a function or class definition.

Furthermore consider this example:

import os
import sys
from subprocess import check_output, DEVNULL

This also fails the lint. Why? Because DEVNULL should come before
check_output. Again, the lint doesn't explain this and you're left
guessing what horrible formatting sin you committed.

Considering the amount of time I wasted trying to even understand this
and I still don't, just delete it. How are contributors supposed to
understand what this lint wants when the project's own developers were
confused by it. Please just alphabetically sort your python imports and
don't do "from foo import *".
This commit is contained in:
Dudemanguy 2025-02-05 15:12:26 -06:00
parent 05ff82e153
commit d19bb08bef

View File

@ -5,7 +5,6 @@ line-length = 100
select = [
"F", # pyflakes
"E", "W", # pycodestyle
"I", # pycodestyle
"N", # pep8-naming
"UP", # pyupgrade
"A", # flake8-builtins