public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tom@tromey.com>
Cc: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Add flake8 and isort to .pre-commit-config.yaml
Date: Wed, 3 Apr 2024 15:57:44 -0400	[thread overview]
Message-ID: <da0e56c0-122f-4443-8458-a0ea74e6789c@simark.ca> (raw)
In-Reply-To: <87il0y6x62.fsf@tromey.com>

On 4/3/24 3:52 PM, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
> 
> Simon> If we want to make pre-commit consider that file for our Python hooks,
> Simon> the only solution I see currently would be to use something like this,
> Simon> as described in the doc above:
> 
> I did this in v2.  Let me know what you think.
> 
> Tom
> 
> commit c3c3740f73b5f20697074c5a20a26d0805afbb98
> Author: Tom Tromey <tromey@adacore.com>
> Date:   Tue Apr 2 12:04:21 2024 -0600
> 
>     Add flake8 and isort to .pre-commit-config.yaml
>     
>     This adds flake8 and isort to .pre-commit-config.yaml.  This way, they
>     will automatically be run on commit.
>     
>     I chose the most recent available versions after verifying that they
>     don't cause any reports or changes in the current tree.
>     
>     Internally at AdaCore, we also use a few flake8 plugins as well, so
>     perhaps that's another avenue for investigation.
>     
>     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.
> 
> 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 <http://www.gnu.org/licenses/>.
>  
> -import gdb
>  import os.path
>  
> +import gdb
> +
>  
>  class TypeFlag:
>      """A class that allows us to store a flag name, its short name,

Thanks, LGTM.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon

  reply	other threads:[~2024-04-03 19:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-02 18:11 Tom Tromey
2024-04-02 20:26 ` Simon Marchi
2024-04-03 19:52   ` Tom Tromey
2024-04-03 19:57     ` Simon Marchi [this message]
2024-04-09  7:58       ` Tom de Vries
2024-04-09  9:41         ` Kévin Le Gouguec
2024-04-09 12:56           ` Tom de Vries
2024-04-09 13:04             ` Kévin Le Gouguec
2024-04-09 15:22         ` Tom Tromey
2024-04-10  5:38           ` Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=da0e56c0-122f-4443-8458-a0ea74e6789c@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    --cc=tromey@adacore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).