On 6/1/24 06:53, José Matos wrote:
On Fri, 2024-05-31 at 12:54 -0400, Richard Kimberly Heck wrote:
I'm especially thinking of older files (say, lyx_1_5.py) that will
not get much testing. It'd be bad to break one of those.
I know that I am revisiting this but I want to give further context to
why I am doing this.

I am testing with tools that were developed for Python 3 and this is
revealing bugs in code/even in older code.

Point in case, I am using mypy (in order to use type annotations that
can be used for type hinting).

Running this I identified two cases that are real bugs:
lyx_2_0.py:2304: error: Function "check_passthru" could always be true
in boolean context  [truthy-function]
lyx_2_0.py:2369: error: Function "check_passthru" could always be true
in boolean context  [truthy-function]

The code reads as
      if not check_passthru:
         return

but check_passthru is a function and thus the result is always true.

The code should have been
      if not check_passthru(document):
         return

Ouch!

I'm all for more readable code, and if it will help make the code safer, that's a bonus.

Riki


--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to