From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, "Eduardo Habkost" <ehabkost@redhat.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: Re: [PATCH] tests: add a "check-flake8" test for validating python code style
Date: Thu, 30 Apr 2020 11:39:05 +0100 [thread overview]
Message-ID: <20200430103905.GJ2084570@redhat.com> (raw)
In-Reply-To: <9f000680-d32a-5e43-d45b-58391063b7fc@redhat.com>
On Thu, Apr 30, 2020 at 12:29:28PM +0200, Paolo Bonzini wrote:
> On 29/04/20 17:36, Daniel P. Berrangé wrote:
> > The flake8 program is a standard tool used by Python projects for
> > validating many commonly recommended style rules. It would be desirable
> > for QEMU to come into alignment with normal Python coding style best
> > practices.
> >
> > QEMU currently violates a huge number of the style rules, so we can't
> > blindly turn it on. Instead this patch introduces use of flake8 with
> > a huge ignore list to turn off everything that is currently violated.
> >
> > The following descriptions are mostly taken from:
> >
> > https://www.flake8rules.com/
>
> I suggest instead using "black" and just reformat everything in a huge
> patch; that's what we're using for Patchew.
Personally I'm a fan of automated code formatters that can enforce a
specific style, so no objection from me.
> It's not perfect, and especially one needs to get used to the double
> quotes instead of single quotes for strings. However overall it is
> pretty good, and I've never seen it do something clearly "wrong".
I've not looked at black in any detail, but if its focused on code
style, then there might be a few bits from flake8 that are still
useful, such as checking for unused imports, or unresolved variable
names. Then again, perhaps Jon's pylint stuff will already catch
that.
> > On its own this patch doesn't really do much of use except try to stop the
> > situation getting worse. To be valuable some motivated contributor(s)
> > would need to go through fixing the code, and re-enabling each excluded
> > warning category one at a time.
> >
> > I'm mostly proposing this patch as a starting point for discussion, to
> > see if anyone is indeed motivated to take on the code cleanup challenge,
> > and feed the fixes in through the various maintainers trees.
>
> If we go with "black" I suggest just doing a big patch for everything,
> since it's easy for maintainers to rebase by running black at each step.
> Overall our usage of Python is small enough that it should not be a big
> deal.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
prev parent reply other threads:[~2020-04-30 10:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-29 15:36 [PATCH] tests: add a "check-flake8" test for validating python code style Daniel P. Berrangé
2020-04-29 19:21 ` John Snow
2020-04-30 5:23 ` Markus Armbruster
2020-04-30 8:55 ` Daniel P. Berrangé
2020-04-30 13:40 ` Markus Armbruster
2020-04-30 10:29 ` Paolo Bonzini
2020-04-30 10:39 ` Daniel P. Berrangé [this message]
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=20200430103905.GJ2084570@redhat.com \
--to=berrange@redhat.com \
--cc=ehabkost@redhat.com \
--cc=f4bug@amsat.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 NNTP newsgroup(s).