pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.32k stars 1.14k forks source link

Cannot disable C1805 #9961

Closed sanmai-NL closed 2 weeks ago

sanmai-NL commented 1 month ago

Bug description

I cannot manage to get Pylint to disable a certain message, be it in pyproject.toml or from the command line.

Configuration

[tool.pylint."messages control"]
disable = [
  "all",
  "use-implicit-booleaness-not-comparison-to-zero",
  "use-implicit-booleaness-not-comparison",
  "use-implicit-booleaness-not-len",
  "C1805"]
enable = [
  "abstract-class-instantiated",
  "abstract-method",
  "access-member-before-definition",
  "anomalous-unicode-escape-in-string",
  "arguments-differ",
  "arguments-out-of-order",
  "arguments-renamed",
  "assigning-non-slot",
  "assignment-from-no-return",
  "assignment-from-none",
  "attribute-defined-outside-init",
  "bad-builtin",
  "bad-except-order",
  "bad-exception-cause",
  "bad-file-encoding",
  "bad-indentation",
  "bad-mcs-classmethod-argument",
  "bad-mcs-method-argument",
  "bad-reversed-sequence",
  "bad-staticmethod-argument",
  "bad-super-call",
  "bad-thread-instantiation",
  "catching-non-exception",
  "chained-comparison",
  "class-variable-slots-conflict",
  "compare-to-zero",
  "comparison-with-callable",
  "condition-evals-to-constant",
  "confusing-consecutive-elif",
  "confusing-with-statement",
  "consider-swap-variables",
  "consider-using-assignment-expr",
  "consider-using-augmented-assign",
  "consider-using-dict-items",
  "consider-using-enumerate",
  "consider-using-f-string",
  "consider-using-from-import",
  "consider-using-join",
  "consider-using-max-builtin",
  "consider-using-min-builtin",
  "consider-using-namedtuple-or-dataclass",
  "consider-using-tuple",
  "consider-using-with",
  "cyclic-import",
  "deprecated-argument",
  "deprecated-class",
  "deprecated-decorator",
  "deprecated-method",
  "deprecated-module",
  "deprecated-typing-alias",
  "dict-init-mutate",
  "dict-iter-missing-items",
  "differing-param-doc",
  "differing-type-doc",
  "disallowed-name",
  "duplicate-code",
  "empty-comment",
  "global-at-module-level",
  "global-variable-undefined",
  "import-error",
  "import-private-name",
  "inconsistent-mro",
  "inherit-non-class",
  "invalid-bool-returned",
  "invalid-bytes-returned",
  "invalid-character-carriage-return",
  "invalid-characters-in-docstring",
  "invalid-class-object",
  "invalid-enum-extension",
  "invalid-envvar-value",
  "invalid-format-index",
  "invalid-format-returned",
  "invalid-getnewargs-ex-returned",
  "invalid-getnewargs-returned",
  "invalid-hash-returned",
  "invalid-index-returned",
  "invalid-length-hint-returned",
  "invalid-length-returned",
  "invalid-metaclass",
  "invalid-overridden-method",
  "invalid-repr-returned",
  "invalid-sequence-index",
  "invalid-slice-index",
  "invalid-slice-step",
  "invalid-slots",
  "invalid-slots-object",
  "invalid-star-assignment-target",
  "invalid-str-returned",
  "invalid-unary-operand-type",
  "invalid-unicode-codec",
  "isinstance-second-argument-not-valid-type",
  "logging-format-truncated",
  "logging-unsupported-format",
  "method-cache-max-size-none",
  "method-hidden",
  "misplaced-format-function",
  "missing-any-param-doc",
  "missing-format-attribute",
  "missing-kwoa",
  "missing-param-doc",
  "missing-parentheses-for-call-in-test",
  "missing-raises-doc",
  "missing-return-doc",
  "missing-return-type-doc",
  "missing-timeout",
  "missing-type-doc",
  "missing-yield-doc",
  "missing-yield-type-doc",
  "mixed-line-endings",
  "modified-iterating-dict",
  "modified-iterating-list",
  "modified-iterating-set",
  "multiple-constructor-doc",
  "nan-comparison",
  "no-member",
  "no-name-in-module",
  "no-value-for-parameter",
  "non-iterator-returned",
  "non-parent-init-called",
  "non-str-assignment-to-dunder-name",
  "nonlocal-and-global",
  "not-a-mapping",
  "not-an-iterable",
  "not-async-context-manager",
  "not-callable",
  "not-context-manager",
  "overlapping-except",
  "overridden-final-method",
  "pointless-string-statement",
  "possibly-unused-variable",
  "potential-index-error",
  "preferred-module",
  "raising-bad-type",
  "raising-format-tuple",
  "raising-non-exception",
  "redeclared-assigned-name",
  "redefined-outer-name",
  "redefined-slots-in-subclass",
  "redefined-variable-type",
  "redundant-keyword-arg",
  "redundant-returns-doc",
  "redundant-u-string-prefix",
  "redundant-unittest-assert",
  "redundant-yields-doc",
  "self-cls-assignment",
  "shallow-copy-environ",
  "signature-differs",
  "simplifiable-condition",
  "simplifiable-if-expression",
  "simplifiable-if-statement",
  "simplify-boolean-expression",
  "singledispatch-method",
  "singledispatchmethod-function",
  "star-needs-assignment-target",
  "stop-iteration-return",
  "subclassed-final-class",
  "super-init-not-called",
  "super-without-brackets",
  "superfluous-parens",
  "too-few-public-methods",
  "too-many-ancestors",
  "too-many-function-args",
  "too-many-instance-attributes",
  "too-many-lines",
  "too-many-nested-blocks",
  "too-many-try-statements",
  "trailing-newlines",
  "trailing-whitespace",
  "unbalanced-dict-unpacking",
  "unbalanced-tuple-unpacking",
  "undefined-loop-variable",
  "unexpected-keyword-arg",
  "unexpected-line-ending-format",
  "unhashable-member",
  "unnecessary-dunder-call",
  "unnecessary-ellipsis",
  "unpacking-non-sequence",
  "unreachable",
  "unsubscriptable-object",
  "unsupported-assignment-operation",
  "unsupported-binary-operation",
  "unsupported-delete-operation",
  "unsupported-membership-test",
  "unused-private-member",
  "unused-wildcard-import",
  "use-maxsplit-arg",
  "used-before-assignment",
  "useless-param-doc",
  "useless-parent-delegation",
  "useless-type-doc",
  "using-constant-test",
  "using-final-decorator-in-unsupported-version",
  "while-used",
  "wrong-exception-operation",
  "wrong-spelling-in-comment",
  "wrong-spelling-in-docstring",
]

Command used

pylint --list-msgs-enabled --disable use-implicit-booleaness-not-comparison-to-zero --disable C1805

Pylint output

Enabled messages:
  disallowed-name (C0104)
  consider-using-enumerate (C0200)
  bad-mcs-method-argument (C0203)
  bad-mcs-classmethod-argument (C0204)
  consider-using-dict-items (C0206)
  use-maxsplit-arg (C0207)
  consider-using-f-string (C0209)
  too-many-lines (C0302)
  trailing-whitespace (C0303)
  trailing-newlines (C0305)
  superfluous-parens (C0325)
  mixed-line-endings (C0327)
  unexpected-line-ending-format (C0328)
  wrong-spelling-in-comment (C0401)
  wrong-spelling-in-docstring (C0402)
  invalid-characters-in-docstring (C0403)
  **use-implicit-booleaness-not-comparison-to-zero (C1805)**
  bad-file-encoding (C2503)
  unnecessary-dunder-call (C2801)
  syntax-error (E0001)
  unrecognized-inline-option (E0011)
  bad-plugin-value (E0013)
  bad-configuration-section (E0014)
  unrecognized-option (E0015)
  abstract-class-instantiated (E0110)
  bad-reversed-sequence (E0111)
  invalid-star-assignment-target (E0113)
  star-needs-assignment-target (E0114)
  nonlocal-and-global (E0115)
  misplaced-format-function (E0119)
  method-hidden (E0202)
  access-member-before-definition (E0203)
  invalid-slots-object (E0236)
  assigning-non-slot (E0237)
  invalid-slots (E0238)
  inherit-non-class (E0239)
  inconsistent-mro (E0240)
  class-variable-slots-conflict (E0242)
  invalid-class-object (E0243)
  invalid-enum-extension (E0244)
  non-iterator-returned (E0301)
  invalid-length-returned (E0303)
  invalid-bool-returned (E0304)
  invalid-index-returned (E0305)
  invalid-repr-returned (E0306)
  invalid-str-returned (E0307)
  invalid-bytes-returned (E0308)
  invalid-hash-returned (E0309)
  invalid-length-hint-returned (E0310)
  invalid-format-returned (E0311)
  invalid-getnewargs-returned (E0312)
  invalid-getnewargs-ex-returned (E0313)
  import-error (E0401)
  used-before-assignment (E0601)
  no-name-in-module (E0611)
  unpacking-non-sequence (E0633)
  potential-index-error (E0643)
  bad-except-order (E0701)
  raising-bad-type (E0702)
  bad-exception-cause (E0705)
  raising-non-exception (E0710)
  catching-non-exception (E0712)
  bad-super-call (E1003)
  no-member (E1101)
  not-callable (E1102)
  assignment-from-no-return (E1111)
  no-value-for-parameter (E1120)
  too-many-function-args (E1121)
  unexpected-keyword-arg (E1123)
  redundant-keyword-arg (E1124)
  missing-kwoa (E1125)
  invalid-sequence-index (E1126)
  invalid-slice-index (E1127)
  assignment-from-none (E1128)
  not-context-manager (E1129)
  invalid-unary-operand-type (E1130)
  unsupported-binary-operation (E1131)
  not-an-iterable (E1133)
  not-a-mapping (E1134)
  unsupported-membership-test (E1135)
  unsubscriptable-object (E1136)
  unsupported-assignment-operation (E1137)
  unsupported-delete-operation (E1138)
  invalid-metaclass (E1139)
  dict-iter-missing-items (E1141)
  unhashable-member (E1143)
  invalid-slice-step (E1144)
  logging-unsupported-format (E1200)
  logging-format-truncated (E1201)
  invalid-envvar-value (E1507)
  singledispatch-method (E1519)
  singledispatchmethod-function (E1520)
  not-async-context-manager (E1701)
  invalid-unicode-codec (E2501)
  invalid-character-carriage-return (E2511)
  modified-iterating-dict (E4702)
  modified-iterating-set (E4703)
  fatal (F0001)
  astroid-error (F0002)
  parse-error (F0010)
  config-parse-error (F0011)
  useless-option-value (R0022)
  cyclic-import (R0401)
  consider-using-from-import (R0402)
  duplicate-code (R0801)
  too-many-ancestors (R0901)
  too-many-instance-attributes (R0902)
  too-few-public-methods (R0903)
  too-many-nested-blocks (R1702)
  simplifiable-if-statement (R1703)
  stop-iteration-return (R1708)
  simplify-boolean-expression (R1709)
  consider-swap-variables (R1712)
  consider-using-join (R1713)
  chained-comparison (R1716)
  simplifiable-if-expression (R1719)
  simplifiable-condition (R1726)
  condition-evals-to-constant (R1727)
  consider-using-min-builtin (R1730)
  consider-using-max-builtin (R1731)
  consider-using-with (R1732)
  unknown-option-value (W0012)
  unreachable (W0101)
  pointless-string-statement (W0105)
  confusing-with-statement (W0124)
  using-constant-test (W0125)
  missing-parentheses-for-call-in-test (W0126)
  redeclared-assigned-name (W0128)
  comparison-with-callable (W0143)
  nan-comparison (W0177)
  attribute-defined-outside-init (W0201)
  bad-staticmethod-argument (W0211)
  arguments-differ (W0221)
  signature-differs (W0222)
  abstract-method (W0223)
  super-init-not-called (W0231)
  non-parent-init-called (W0233)
  invalid-overridden-method (W0236)
  arguments-renamed (W0237)
  unused-private-member (W0238)
  overridden-final-method (W0239)
  subclassed-final-class (W0240)
  redefined-slots-in-subclass (W0244)
  super-without-brackets (W0245)
  useless-parent-delegation (W0246)
  bad-indentation (W0311)
  preferred-module (W0407)
  global-variable-undefined (W0601)
  global-at-module-level (W0604)
  unused-wildcard-import (W0614)
  redefined-outer-name (W0621)
  undefined-loop-variable (W0631)
  unbalanced-tuple-unpacking (W0632)
  possibly-unused-variable (W0641)
  self-cls-assignment (W0642)
  unbalanced-dict-unpacking (W0644)
  raising-format-tuple (W0715)
  wrong-exception-operation (W0716)
  arguments-out-of-order (W1114)
  non-str-assignment-to-dunder-name (W1115)
  isinstance-second-argument-not-valid-type (W1116)
  missing-format-attribute (W1306)
  invalid-format-index (W1307)
  anomalous-unicode-escape-in-string (W1402)
  redundant-u-string-prefix (W1406)
  redundant-unittest-assert (W1503)
  bad-thread-instantiation (W1506)
  shallow-copy-environ (W1507)
  method-cache-max-size-none (W1518)
  unnecessary-ellipsis (W2301)
  using-final-decorator-in-unsupported-version (W2602)
  missing-timeout (W3101)
  modified-iterating-list (W4701)
  deprecated-module (W4901)
  deprecated-method (W4902)
  deprecated-argument (W4903)
  deprecated-class (W4904)
  deprecated-decorator (W4905)

Disabled messages:
  invalid-name (C0103)
  typevar-name-incorrect-variance (C0105)
  empty-docstring (C0112)
  missing-module-docstring (C0114)
  missing-class-docstring (C0115)
  missing-function-docstring (C0116)
  unnecessary-negation (C0117)
  singleton-comparison (C0121)
  unidiomatic-typecheck (C0123)
  typevar-double-variance (C0131)
  typevar-name-mismatch (C0132)
  consider-iterating-dictionary (C0201)
  bad-classmethod-argument (C0202)
  single-string-used-for-slots (C0205)
  use-sequence-for-iteration (C0208)
  line-too-long (C0301)
  missing-final-newline (C0304)
  multiple-statements (C0321)
  multiple-imports (C0410)
  wrong-import-order (C0411)
  ungrouped-imports (C0412)
  wrong-import-position (C0413)
  useless-import-alias (C0414)
  import-outside-toplevel (C0415)
  **use-implicit-booleaness-not-len (C1802)**
  **use-implicit-booleaness-not-comparison (C1803)**
  **use-implicit-booleaness-not-comparison-to-string (C1804)**
  non-ascii-name (C2401)
  non-ascii-module-import (C2403)
  unnecessary-lambda-assignment (C3001)
  unnecessary-direct-lambda-call (C3002)
  init-is-generator (E0100)
  return-in-init (E0101)
  function-redefined (E0102)
  not-in-loop (E0103)
  return-outside-function (E0104)
  yield-outside-function (E0105)
  nonexistent-operator (E0107)
  duplicate-argument-name (E0108)
  too-many-star-expressions (E0112)
  continue-in-finally (E0116)
  nonlocal-without-binding (E0117)
  used-prior-global-declaration (E0118)
  no-method-argument (E0211)
  no-self-argument (E0213)
  duplicate-bases (E0241)
  declare-non-slot (E0245)
  unexpected-special-method-signature (E0302)
  relative-beyond-top-level (E0402)
  undefined-variable (E0602)
  undefined-all-variable (E0603)
  invalid-all-object (E0604)
  invalid-all-format (E0605)
  possibly-used-before-assignment (E0606)
  misplaced-bare-raise (E0704)
  notimplemented-raised (E0711)
  repeated-keyword (E1132)
  await-outside-async (E1142)
  logging-too-many-args (E1205)
  logging-too-few-args (E1206)
  bad-format-character (E1300)
  truncated-format-string (E1301)
  mixed-format-string (E1302)
  format-needs-mapping (E1303)
  missing-format-string-key (E1304)
  too-many-format-args (E1305)
  too-few-format-args (E1306)
  bad-string-format-type (E1307)
  bad-str-strip-call (E1310)
  yield-inside-async-function (E1700)
  bidirectional-unicode (E2502)
  invalid-character-backspace (E2510)
  invalid-character-sub (E2512)
  invalid-character-esc (E2513)
  invalid-character-nul (E2514)
  invalid-character-zero-width-space (E2515)
  positional-only-arguments-expected (E3102)
  invalid-field-call (E3701)
  method-check-failed (F0202)
  raw-checker-failed (I0001)
  bad-inline-option (I0010)
  locally-disabled (I0011)
  file-ignored (I0013)
  suppressed-message (I0020)
  useless-suppression (I0021)
  deprecated-pragma (I0022)
  use-symbolic-message-instead (I0023)
  c-extension-no-member (I1101)
  literal-comparison (R0123)
  comparison-with-itself (R0124)
  comparison-of-constants (R0133)
  no-classmethod-decorator (R0202)
  no-staticmethod-decorator (R0203)
  useless-object-inheritance (R0205)
  property-with-parameters (R0206)
  too-many-public-methods (R0904)
  too-many-return-statements (R0911)
  too-many-branches (R0912)
  too-many-arguments (R0913)
  too-many-locals (R0914)
  too-many-statements (R0915)
  too-many-boolean-expressions (R0916)
  too-many-positional-arguments (R0917)
  consider-merging-isinstance (R1701)
  redefined-argument-from-local (R1704)
  no-else-return (R1705)
  consider-using-ternary (R1706)
  trailing-comma-tuple (R1707)
  inconsistent-return-statements (R1710)
  useless-return (R1711)
  consider-using-in (R1714)
  consider-using-get (R1715)
  consider-using-dict-comprehension (R1717)
  consider-using-set-comprehension (R1718)
  no-else-raise (R1720)
  unnecessary-comprehension (R1721)
  consider-using-sys-exit (R1722)
  no-else-break (R1723)
  no-else-continue (R1724)
  super-with-arguments (R1725)
  consider-using-generator (R1728)
  use-a-generator (R1729)
  unnecessary-dict-index-lookup (R1733)
  use-list-literal (R1734)
  use-dict-literal (R1735)
  unnecessary-list-index-lookup (R1736)
  use-yield-from (R1737)
  dangerous-default-value (W0102)
  pointless-statement (W0104)
  expression-not-assigned (W0106)
  unnecessary-pass (W0107)
  unnecessary-lambda (W0108)
  duplicate-key (W0109)
  useless-else-on-loop (W0120)
  exec-used (W0122)
  eval-used (W0123)
  self-assigning-variable (W0127)
  assert-on-string-literal (W0129)
  duplicate-value (W0130)
  named-expr-without-context (W0131)
  pointless-exception-statement (W0133)
  return-in-finally (W0134)
  contextmanager-generator-missing-cleanup (W0135)
  lost-exception (W0150)
  assert-on-tuple (W0199)
  protected-access (W0212)
  implicit-flag-alias (W0213)
  unnecessary-semicolon (W0301)
  wildcard-import (W0401)
  reimported (W0404)
  import-self (W0406)
  misplaced-future (W0410)
  shadowed-import (W0416)
  fixme (W0511)
  global-variable-not-assigned (W0602)
  global-statement (W0603)
  unused-import (W0611)
  unused-variable (W0612)
  unused-argument (W0613)
  redefined-builtin (W0622)
  cell-var-from-loop (W0640)
  bare-except (W0702)
  duplicate-except (W0705)
  try-except-raise (W0706)
  raise-missing-from (W0707)
  binary-op-exception (W0711)
  broad-exception-caught (W0718)
  broad-exception-raised (W0719)
  keyword-arg-before-vararg (W1113)
  kwarg-superseded-by-positional-arg (W1117)
  logging-not-lazy (W1201)
  logging-format-interpolation (W1202)
  logging-fstring-interpolation (W1203)
  bad-format-string-key (W1300)
  unused-format-string-key (W1301)
  bad-format-string (W1302)
  missing-format-argument-key (W1303)
  unused-format-string-argument (W1304)
  format-combined-specification (W1305)
  duplicate-string-formatting-argument (W1308)
  f-string-without-interpolation (W1309)
  format-string-without-interpolation (W1310)
  anomalous-backslash-in-string (W1401)
  implicit-str-concat (W1404)
  inconsistent-quotes (W1405)
  bad-open-mode (W1501)
  invalid-envvar-default (W1508)
  subprocess-popen-preexec-fn (W1509)
  subprocess-run-check (W1510)
  unspecified-encoding (W1514)
  forgotten-debug-statement (W1515)
  useless-with-lock (W2101)
  non-ascii-file-name (W2402)
  using-f-string-in-unsupported-version (W2601)
  using-exception-groups-in-unsupported-version (W2603)
  using-generic-type-syntax-in-unsupported-version (W2604)
  using-assignment-expression-in-unsupported-version (W2605)
  using-positional-only-args-in-unsupported-version (W2606)
  nested-min-max (W3301)
  bad-chained-comparison (W3601)
  deprecated-attribute (W4906)

Non-emittable messages with current interpreter:
  return-arg-in-generator (E0106)
  boolean-datetime (W1502)

Expected behavior

Pylint version

pylint 3.3.0
astroid 3.3.3
Python 3.12.6 (main, Sep  6 2024, 19:03:47) [Clang 15.0.0 (clang-1500.3.9.4)]

OS / Environment

macOS

Additional dependencies

No response

Pierre-Sassoulas commented 1 month ago

Thank you for opening the issue, I cannot reproduce. Both the disable in pyproject.toml and the command line should work (and the command line will takes precedence).

sanmai-NL commented 1 month ago

How can I trace which configuration objects are being applied?

Pierre-Sassoulas commented 1 month ago

Maybe in verbose mode, not sure. There's a bunch of place where a pylint conf file can be stored (home dir, repo root, etc.), but the command line option should always take precedence so I don't know where the problem is but probably not with a hidden conf file.

https://github.com/pylint-dev/pylint/blob/88e4bc65f42cf6849ef31f140aab7b42ef9de1ca/pylint/config/find_default_config_files.py#L18-L25

https://github.com/pylint-dev/pylint/blob/88e4bc65f42cf6849ef31f140aab7b42ef9de1ca/pylint/config/find_default_config_files.py#L70-L85

github-actions[bot] commented 3 weeks ago

This issue is stale because it has been open 4 weeks with no activity. Remove 'Stale' label or comment or this will be closed in a week.

github-actions[bot] commented 2 weeks ago

This issue was closed because it has been stalled for five weeks with no activity.

sanmai-NL commented 2 weeks ago

Not stale.

Pierre-Sassoulas commented 2 weeks ago

We can't reproduce so unless you can provide more info this is not actionable.

sanmai-NL commented 2 weeks ago

What additional info do you desire?

Best way out is if I could debug Pylints config resolution locally. But from what you wrote, it seems Pylint has no facilities for that.

Pierre-Sassoulas commented 2 weeks ago

Maybe you have a downloadable online repo where this reproduce ?