From a927a93d2833de61cdf85defb88b94ef8e17d51b Mon Sep 17 00:00:00 2001 From: toofar Date: Sun, 15 Oct 2023 16:45:22 +1300 Subject: lint: allow comparing variables to 0 With pylint 3 there is a new option: https://pylint.readthedocs.io/en/latest/user_guide/messages/convention/use-implicit-booleaness-not-comparison-to-zero.html It's disabled by default but we enable all warnings and disabled them as desired. This one is of the opinion that: if x == 0: is bad and if x: is good. I feel that the first one (x == 0) is more clear. We aren't checking for truthiness here, we are checking for a literal value, its very intentional. One might argue that being precious about making the type here is redundant in current year with type checking tooling and all that. But there are like a hundred of these checks in the code base so it seems a well established pattern anyhow. In summary, the new warning doesn't have a very strong use case and we would prefer to stick with out established pattern. --- .pylintrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.pylintrc b/.pylintrc index 46a8ae2e8..a6784c0e4 100644 --- a/.pylintrc +++ b/.pylintrc @@ -59,6 +59,7 @@ disable=locally-disabled, useless-param-doc, wrong-import-order, # doesn't work with qutebrowser.qt, even with known-third-party set ungrouped-imports, # ditto + use-implicit-booleaness-not-comparison-to-zero, [BASIC] function-rgx=[a-z_][a-z0-9_]{2,50}$ -- cgit v1.2.3-54-g00ecf