mirror of https://github.com/mpv-player/mpv
ci/lint: add python linting
Enabled the ruff python linter in CI, and resolved the issues that were detected by it. Ruff was used due to it's faster checking compared with other linters like pylint. This was added to resolve the python linting request in #13608.
This commit is contained in:
parent
f46975c2d2
commit
bee3598ba6
|
@ -33,3 +33,9 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: lunarmodules/luacheck@v1
|
||||
|
||||
python-lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: chartboost/ruff-action@v1
|
||||
|
|
|
@ -58,7 +58,7 @@ try:
|
|||
proc = subprocess.run(argv, check=True)
|
||||
if depfile is not None:
|
||||
convert_depfile(output, depfile)
|
||||
except:
|
||||
except Exception:
|
||||
remove(output)
|
||||
if depfile is not None:
|
||||
remove(depfile)
|
||||
|
|
|
@ -16,13 +16,13 @@ def is_user_lib(objfile, libname):
|
|||
return not sys_re.match(libname) and \
|
||||
not usr_re.match(libname) and \
|
||||
not exe_re.match(libname) and \
|
||||
not "libobjc." in libname and \
|
||||
not "libSystem." in libname and \
|
||||
not "libc." in libname and \
|
||||
not "libgcc." in libname and \
|
||||
"libobjc." not in libname and \
|
||||
"libSystem." not in libname and \
|
||||
"libc." not in libname and \
|
||||
"libgcc." not in libname and \
|
||||
not os.path.basename(libname) == 'Python' and \
|
||||
not os.path.basename(objfile) in libname and \
|
||||
not "libswift" in libname
|
||||
os.path.basename(objfile) not in libname and \
|
||||
"libswift" not in libname
|
||||
|
||||
def otool(objfile, rapths):
|
||||
command = "otool -L '%s' | grep -e '\t' | awk '{ print $1 }'" % objfile
|
||||
|
@ -46,7 +46,7 @@ def get_rapths(objfile):
|
|||
|
||||
try:
|
||||
result = subprocess.check_output(command, shell = True, universal_newlines=True)
|
||||
except:
|
||||
except Exception:
|
||||
return rpaths
|
||||
|
||||
for line in result.splitlines():
|
||||
|
@ -90,9 +90,9 @@ def resolve_lib_path(objfile, lib, rapths):
|
|||
|
||||
def check_vulkan_max_version(version):
|
||||
try:
|
||||
result = subprocess.check_output("pkg-config vulkan --max-version=" + version, shell = True)
|
||||
subprocess.check_output("pkg-config vulkan --max-version=" + version, shell = True)
|
||||
return True
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
def get_homebrew_prefix():
|
||||
|
@ -100,7 +100,7 @@ def get_homebrew_prefix():
|
|||
result = "/opt/homebrew"
|
||||
try:
|
||||
result = subprocess.check_output("brew --prefix", universal_newlines=True, shell=True, stderr=subprocess.DEVNULL).strip()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return result
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
# This checks for the sdk path, the sdk version, and
|
||||
# the sdk build version.
|
||||
|
||||
import re
|
||||
import os
|
||||
import string
|
||||
import subprocess
|
||||
import sys
|
||||
from shutil import which
|
||||
|
@ -33,7 +31,7 @@ def find_macos_sdk():
|
|||
try:
|
||||
sdk_version = check_output([xcodebuild, '-sdk', 'macosx', '-version', 'ProductVersion'],
|
||||
encoding="UTF-8", stderr=subprocess.DEVNULL)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if not isinstance(sdk_version, str):
|
||||
|
|
|
@ -4,6 +4,10 @@ Generate C definitions for parsing Matroska files.
|
|||
Can also be used to directly parse Matroska files and display their contents.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from math import ldexp
|
||||
from binascii import hexlify
|
||||
|
||||
#
|
||||
# This file is part of mpv.
|
||||
#
|
||||
|
@ -242,14 +246,11 @@ elements_matroska = (
|
|||
)
|
||||
|
||||
|
||||
import sys
|
||||
from math import ldexp
|
||||
from binascii import hexlify
|
||||
|
||||
def byte2num(s):
|
||||
return int(hexlify(s), 16)
|
||||
|
||||
class EOF(Exception): pass
|
||||
class EOF(Exception):
|
||||
pass
|
||||
|
||||
def camelcase_to_words(name):
|
||||
parts = []
|
||||
|
@ -291,9 +292,9 @@ class MatroskaElement(object):
|
|||
|
||||
elementd = {}
|
||||
elementlist = []
|
||||
def parse_elems(l, namespace):
|
||||
def parse_elems(elements, namespace):
|
||||
subelements = []
|
||||
for el in l:
|
||||
for el in elements:
|
||||
if isinstance(el, str):
|
||||
name, hexid, eltype = [x.strip() for x in el.split(',')]
|
||||
hexid = hexid.lower()
|
||||
|
@ -328,10 +329,10 @@ def generate_C_header(out):
|
|||
continue
|
||||
printf(out)
|
||||
printf(out, 'struct {0.structname} {{'.format(el))
|
||||
l = max(len(subel.valname) for subel, multiple in el.subelements)+1
|
||||
length = max(len(subel.valname) for subel, multiple in el.subelements)+1
|
||||
for subel, multiple in el.subelements:
|
||||
printf(out, ' {e.valname:{l}} {star}{e.fieldname};'.format(
|
||||
e=subel, l=l, star=' *'[multiple]))
|
||||
printf(out, ' {e.valname:{length}} {star}{e.fieldname};'.format(
|
||||
e=subel, length=length, star=' *'[multiple]))
|
||||
printf(out)
|
||||
for subel, multiple in el.subelements:
|
||||
printf(out, ' int n_{0.fieldname};'.format(subel))
|
||||
|
|
|
@ -161,7 +161,7 @@ for cur in ax:
|
|||
|
||||
for e in G.sevents:
|
||||
cur = ax[1 if e.type == "value" else 0]
|
||||
if not cur in G.curveno:
|
||||
if cur not in G.curveno:
|
||||
G.curveno[cur] = 0
|
||||
args = {'name': e.name,'antialias':True}
|
||||
color = mkColor(colors[G.curveno[cur] % len(colors)])
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#!/usr/bin/env python3
|
||||
import os, sys, json, subprocess, re
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import subprocess
|
||||
import re
|
||||
from typing import Dict, Tuple, Callable, Optional
|
||||
|
||||
def call(cmd) -> str:
|
||||
|
|
Loading…
Reference in New Issue