From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 6F7073858C98; Thu, 4 Apr 2024 12:43:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6F7073858C98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1712234638; bh=Tw1Qwb4MGvYc7k09WH5lQUNi6BRKb30J7GD2rejZffY=; h=From:To:Subject:Date:From; b=T6DJyKfiFPFQU5Hon9pSY6ucyAPbgSjbFMlv1Rg+hozJZM0P1g5+ee+YldT1HoRBs wsTq+7sNTnioleMH9KQJO2FS2u8plDy2jCsPO1r0KCbfSZenn49Sv74EY15+Ff/E7h RGJBbbw5e25jI+XdNbqVL7SowhsX8qBQtxr1pfzg= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: binutils-cvs@sourceware.org, gdb-cvs@sourceware.org Subject: [binutils-gdb] Add flake8 and isort to .pre-commit-config.yaml X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: b0ca740e8f361024d1c78cdf7432b4566dda4c7c X-Git-Newrev: 16810e455feb26ef826a3ed876d6d7e6d24818b0 Message-Id: <20240404124358.6F7073858C98@sourceware.org> Date: Thu, 4 Apr 2024 12:43:58 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D16810e455feb= 26ef826a3ed876d6d7e6d24818b0 commit 16810e455feb26ef826a3ed876d6d7e6d24818b0 Author: Tom Tromey Date: Tue Apr 2 12:04:21 2024 -0600 Add flake8 and isort to .pre-commit-config.yaml =20 This adds flake8 and isort to .pre-commit-config.yaml. This way, they will automatically be run on commit. =20 I chose the most recent available versions after verifying that they don't cause any reports or changes in the current tree. =20 Internally at AdaCore, we also use a few flake8 plugins as well, so perhaps that's another avenue for investigation. =20 v2: Also update the various file-selection clauses to pick up gdb-gdb.py.in; include the isort change made to this file; and finally add a comment about the exclusions from flake8. =20 Approved-By: Simon Marchi Diff: --- .pre-commit-config.yaml | 18 +++++++++++++++++- gdb/gdb-gdb.py.in | 3 ++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7afe60c20be..8721dac678b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,4 +5,20 @@ repos: rev: 24.3.0 hooks: - id: black - files: 'gdb/.*' + types_or: [file] + files: 'gdb/.*\.py(\.in)?$' + - repo: https://github.com/pycqa/flake8 + rev: 7.0.0 + hooks: + - id: flake8 + types_or: [file] + # Note this one is only run on gdb/python, not (for now) the + # test suite. + files: 'gdb/python/.*\.py(\.in)?$' + args: [--config, gdb/setup.cfg] + - repo: https://github.com/pycqa/isort + rev: 5.13.2 + hooks: + - id: isort + types_or: [file] + files: 'gdb/.*\.py(\.in)?$' diff --git a/gdb/gdb-gdb.py.in b/gdb/gdb-gdb.py.in index 54db9b00cf3..b5a7fa4f390 100644 --- a/gdb/gdb-gdb.py.in +++ b/gdb/gdb-gdb.py.in @@ -15,9 +15,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . =20 -import gdb import os.path =20 +import gdb + =20 class TypeFlag: """A class that allows us to store a flag name, its short name,