From ab1c75562fa4a3bb3617051068a61dc40f1f0de7 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 27 Nov 2023 18:09:26 +0100 Subject: [PATCH] GitHub Actions: Lint with ruff instead of flake8 --- .github/workflows/python-app.yml | 18 ++++++------------ examples/client.py | 2 +- setup.py | 3 --- wolfssl/__init__.py | 6 +++--- wolfssl/_build_ffi.py | 3 +-- 5 files changed, 11 insertions(+), 21 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 22bb2c4..1875a7e 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -18,23 +18,17 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python 3.10 - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: "3.10" - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest tox + pip install pytest ruff tox pip install -r requirements/test.txt -# Won't pass flake8 yet -# - name: Lint with flake8 -# run: | -# # stop the build if there are Python syntax errors or undefined names -# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics -# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide -# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Lint with ruff + run: ruff . - name: Test with tox - run: | - tox + run: tox diff --git a/examples/client.py b/examples/client.py index f6f1406..8bb0478 100755 --- a/examples/client.py +++ b/examples/client.py @@ -156,7 +156,7 @@ def main(): if not args.C: secure_socket.enable_crl(1) - secure_socket.load_crl_file(args.r, 1); + secure_socket.load_crl_file(args.r, 1) secure_socket.connect((args.h, args.p)) diff --git a/setup.py b/setup.py index 6ef3fb4..6f555dc 100755 --- a/setup.py +++ b/setup.py @@ -21,10 +21,7 @@ # pylint: disable=wrong-import-position -import os -import sys from setuptools import setup -from setuptools.command.build_ext import build_ext import re VERSIONFILE = "wolfssl/_version.py" diff --git a/wolfssl/__init__.py b/wolfssl/__init__.py index f92b38b..65630bd 100644 --- a/wolfssl/__init__.py +++ b/wolfssl/__init__.py @@ -28,7 +28,7 @@ from functools import wraps import errno from socket import ( - socket, AF_INET, SOCK_STREAM, SOL_SOCKET, SO_TYPE, error as socket_error + socket, AF_INET, SOCK_STREAM, error as socket_error ) # pylint: disable=wildcard-import @@ -487,7 +487,7 @@ def server_side(self): """ Returns True for server-side socket, otherwise False. """ - return self._server_side; + return self._server_side def dup(self): raise NotImplementedError("Can't dup() %s instances" % @@ -998,5 +998,5 @@ def _get_passwd(self, passwd, sz, rw, userdata): for i in range(len(result)): passwd[i] = result[i:i + 1] return len(result) - except Exception as e: + except Exception: raise ValueError("Problem getting password from callback") diff --git a/wolfssl/_build_ffi.py b/wolfssl/_build_ffi.py index b8a58a7..418b3c8 100644 --- a/wolfssl/_build_ffi.py +++ b/wolfssl/_build_ffi.py @@ -22,7 +22,6 @@ # pylint: disable=missing-docstring, invalid-name -import argparse from contextlib import contextmanager from distutils.util import get_platform from cffi import FFI @@ -105,7 +104,7 @@ def checkout_ref(ref): current = subprocess.check_output( ["git", "describe", "--all", "--exact-match"] ).strip().decode().split('/')[-1] - except: + except Exception: pass if current != ref: