From 66892b20b4b7d43fba919454cb7935b40ec53501 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Wed, 13 Nov 2024 21:21:07 +0100 Subject: [PATCH] remove dead code --- .github/workflows/bsd.yml | 2 +- .github/workflows/issues.py | 5 --- psutil/_compat.py | 2 +- psutil/tests/test_aix.py | 39 +++++++++++++++++--- psutil/tests/test_linux.py | 5 --- scripts/internal/bench_oneshot_2.py | 4 -- scripts/internal/download_wheels_appveyor.py | 2 - scripts/internal/git_pre_commit.py | 1 - 8 files changed, 35 insertions(+), 25 deletions(-) diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index 5358412a3..c405e8228 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -35,7 +35,7 @@ jobs: PIP_BREAK_SYSTEM_PACKAGES=1 make install-sysdeps install-pydeps-test install print-sysinfo test test-memleaks netbsd: - # if: false + if: false # XXX: disabled runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/issues.py b/.github/workflows/issues.py index eddaa7f99..5e8c2026f 100755 --- a/.github/workflows/issues.py +++ b/.github/workflows/issues.py @@ -144,11 +144,6 @@ def has_label(issue, label): return label in assigned -def has_os_label(issue): - labels = set([x.name for x in issue.labels]) - return any(x in labels for x in OS_LABELS) - - def get_repo(): repo = os.environ['GITHUB_REPOSITORY'] token = os.environ['GITHUB_TOKEN'] diff --git a/psutil/_compat.py b/psutil/_compat.py index 6070c2a04..9631a7c50 100644 --- a/psutil/_compat.py +++ b/psutil/_compat.py @@ -225,7 +225,7 @@ def FileExistsError(inst): "CacheInfo", ["hits", "misses", "maxsize", "currsize"] ) - class _HashedSeq(list): + class _HashedSeq(list): # noqa: FURB189 __slots__ = ('hashvalue',) def __init__(self, tup, hash=hash): diff --git a/psutil/tests/test_aix.py b/psutil/tests/test_aix.py index 68d467b18..2b0f849be 100755 --- a/psutil/tests/test_aix.py +++ b/psutil/tests/test_aix.py @@ -22,7 +22,15 @@ class AIXSpecificTestCase(PsutilTestCase): def test_virtual_memory(self): out = sh('/usr/bin/svmon -O unit=KB') re_pattern = r"memory\s*" - for field in ("size inuse free pin virtual available mmode").split(): + for field in [ + "size", + "inuse", + "free", + "pin", + "virtual", + "available", + "mmode", + ]: re_pattern += r"(?P<%s>\S+)\s+" % (field,) matchobj = re.search(re_pattern, out) @@ -72,11 +80,30 @@ def test_cpu_stats(self): out = sh('/usr/bin/mpstat -a') re_pattern = r"ALL\s*" - for field in ( - "min maj mpcs mpcr dev soft dec ph cs ics bound rq " - "push S3pull S3grd S0rd S1rd S2rd S3rd S4rd S5rd " - "sysc" - ).split(): + for field in [ + "min", + "maj", + "mpcs", + "mpcr", + "dev", + "soft", + "dec", + "ph", + "cs", + "ics", + "bound", + "rq", + "push", + "S3pull", + "S3grd", + "S0rd", + "S1rd", + "S2rd", + "S3rd", + "S4rd", + "S5rd", + "sysc", + ]: re_pattern += r"(?P<%s>\S+)\s+" % (field,) matchobj = re.search(re_pattern, out) diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py index cdcb468e1..dcfd60fbe 100755 --- a/psutil/tests/test_linux.py +++ b/psutil/tests/test_linux.py @@ -11,7 +11,6 @@ import collections import contextlib import errno -import glob import io import os import re @@ -61,15 +60,11 @@ HERE = os.path.abspath(os.path.dirname(__file__)) SIOCGIFADDR = 0x8915 -SIOCGIFCONF = 0x8912 SIOCGIFHWADDR = 0x8927 SIOCGIFNETMASK = 0x891B SIOCGIFBRDADDR = 0x8919 if LINUX: SECTOR_SIZE = 512 -EMPTY_TEMPERATURES = not glob.glob('/sys/class/hwmon/hwmon*') - - # ===================================================================== # --- utils # ===================================================================== diff --git a/scripts/internal/bench_oneshot_2.py b/scripts/internal/bench_oneshot_2.py index fe5151d3e..41c9cbb89 100755 --- a/scripts/internal/bench_oneshot_2.py +++ b/scripts/internal/bench_oneshot_2.py @@ -31,10 +31,6 @@ def call_oneshot(): fun() -def add_cmdline_args(cmd, args): - cmd.append(args.benchmark) - - def main(): runner = pyperf.Runner() diff --git a/scripts/internal/download_wheels_appveyor.py b/scripts/internal/download_wheels_appveyor.py index 0e6490b39..154faeed7 100755 --- a/scripts/internal/download_wheels_appveyor.py +++ b/scripts/internal/download_wheels_appveyor.py @@ -37,12 +37,10 @@ def download_file(url): local_fname = os.path.join('dist', local_fname) os.makedirs('dist', exist_ok=True) r = requests.get(url, stream=True, timeout=TIMEOUT) - tot_bytes = 0 with open(local_fname, 'wb') as f: for chunk in r.iter_content(chunk_size=16384): if chunk: # filter out keep-alive new chunks f.write(chunk) - tot_bytes += len(chunk) return local_fname diff --git a/scripts/internal/git_pre_commit.py b/scripts/internal/git_pre_commit.py index 84c38cccd..1441a1454 100755 --- a/scripts/internal/git_pre_commit.py +++ b/scripts/internal/git_pre_commit.py @@ -20,7 +20,6 @@ PYTHON = sys.executable PY3 = sys.version_info[0] >= 3 -THIS_SCRIPT = os.path.realpath(__file__) def term_supports_colors():