bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Collin Funk <collin.funk1@gmail.com>
To: Bruno Haible <bruno@clisp.org>, bug-gnulib@gnu.org
Subject: Re: [PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 27.
Date: Fri, 23 Feb 2024 18:36:34 -0800	[thread overview]
Message-ID: <9c544e87-9c0a-417b-a56f-0214d8a6f39f@gmail.com> (raw)
In-Reply-To: <7344891.cEBGB3zze1@nimes>

On 2/23/24 3:51 PM, Bruno Haible wrote:
> I.e. you meant to write
>   mode != None
> not
>   modules != None
> ?

Oops. I'm not sure how I missed this in your original email as well...
You are correct. It should be "mode != None". I should have a patch
ready in a bit to fix another item in the gnulib-tool.py.TODO. If you
would like I could fix that typo along with it. Or you can commit the
change yourself if you would prefer. Thanks for the catch.

> I recall having seen this warning. Was it from python itself?
> Or from pycodestyle or pylint? (Cf. the comments at gnulib-tool.py
> line 29..33)
> 
> But I don't recall whether this warning was justified or bogus.

I'd imagine that most of the code linters and style checkers would
warn about it. It seems to be error code E711 for pycodestyle which is
disabled by the command in that comment [1]. I mentioned it more out
of habit though. I tend to find the Python tools confusing so I mostly
avoid them (which is probably a bad habit). There is like 20 separate
linters so I never know which one is the most "standard" if that makes
sense...

The difference between "==" and "is" can cause actual bugs, but those
typically don't involve comparisons to None. It is hard for me to
imagine a situation where it would actually cause problems in that
case. I'm not super familiar with Python though, so maybe someone who
knows better can give their thoughts. Here is a silly example to show
the difference, but of course you would never write it without
intending the consequences. 

class Example:
    def __eq__(self, other):
        return True

def main():
    one = Example()
    print(f"one == None: {one == None}")
    print(f"one == 0:    {one == 0}")
    print(f"one is None: {one is None}")

if __name__ == "__main__":
    main()

[collin@debian gnulib]$ ./test.py 
one == None: True
one == 0:    True
one is None: False

> And I'm not convinced Pathlib is a win here, because
>   - we are not targetting native Windows, only Unix platforms (that
>     includes Cygwin),
>   - it appears to have some extra learning curve besides 'import os'.

Sure, that makes sense. There is definitely less benefit if you are not
concerned with Windows paths. I'll stick to os.path since it seems
everyone is comfortable with it.

[1] https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes


  reply	other threads:[~2024-02-24  2:37 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-23  5:23 [PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 27 Collin Funk
2024-02-23 13:08 ` Bruno Haible
2024-02-23 22:20   ` Collin Funk
2024-02-23 23:51     ` Bruno Haible
2024-02-24  2:36       ` Collin Funk [this message]
2024-02-24  5:49         ` gnulib-tool.py: Follow gnulib-tool changes, part 28 Collin Funk
2024-02-24 23:25           ` gnulib-tool.py: Follow gnulib-tool changes, part 27 Bruno Haible
2024-02-25  0:03             ` Dima Pasechnik
2024-02-25 11:57               ` Python != None Bruno Haible
2024-02-25 19:29                 ` Collin Funk
2024-02-25 20:07                   ` Collin Funk
2024-02-26 20:38                     ` pycodestyle configuration Bruno Haible
2024-02-26 21:31                       ` Collin Funk
2024-02-26 22:54                         ` Bruno Haible
2024-02-27  0:51                           ` Collin Funk
2024-02-27  2:38                             ` Bruno Haible
2024-02-27  4:22                               ` Collin Funk
2024-02-25 20:55                   ` Python != None Dima Pasechnik
2024-02-25 12:02             ` Python 'strings' Bruno Haible
2024-02-25 19:05               ` Collin Funk
2024-02-24 23:42           ` gnulib-tool.py: Follow gnulib-tool changes, part 28 Bruno Haible
2024-02-25  0:47             ` Collin Funk
2024-02-25  1:18               ` Collin Funk
2024-02-25  1:25                 ` Bruno Haible
2024-02-25  3:32                   ` Collin Funk
2024-02-26 20:51                     ` Bruno Haible
2024-02-28 11:51                       ` Collin Funk
2024-02-28 12:14                         ` Bruno Haible

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

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

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

  git send-email \
    --in-reply-to=9c544e87-9c0a-417b-a56f-0214d8a6f39f@gmail.com \
    --to=collin.funk1@gmail.com \
    --cc=bruno@clisp.org \
    --cc=bug-gnulib@gnu.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 read-only IMAP folder(s) and NNTP newsgroup(s).