Skip to content

Fix undefined-variable false positive with metaclass in nested class#10853

Merged
Pierre-Sassoulas merged 1 commit intopylint-dev:mainfrom
worksbyfriday:fix-undefined-variable-metaclass-nested
Feb 22, 2026
Merged

Fix undefined-variable false positive with metaclass in nested class#10853
Pierre-Sassoulas merged 1 commit intopylint-dev:mainfrom
worksbyfriday:fix-undefined-variable-metaclass-nested

Conversation

@worksbyfriday
Copy link
Copy Markdown
Contributor

@worksbyfriday worksbyfriday commented Feb 17, 2026

Description

Fixes #10823
Closes #10823

When an imported name is used as a metaclass= argument inside a nested class within a method, pylint incorrectly flags subsequent uses of that name at module level as undefined-variable.

Reproducer

import abc

class Test:
    def test1(self):
        class A(metaclass=abc.ABCMeta):
            pass

abc.ABCMeta  # E0602: Undefined variable 'abc' (undefined-variable)

Root cause

_check_classdef_metaclasses() walks enclosing scopes to find the name used as a metaclass and collects (scope_locals_dict, name) tuples. Then _check_metaclasses() calls scope_locals.pop(name, None) — removing the name entirely from to_consume in the enclosing scope.

This was intended to prevent unused-import/unused-variable false positives: the metaclass usage should "count" as using the name. But pop() removes the name without moving it to the consumer's consumed dict. Later references to the same name can't find it in either to_consume or consumed, so pylint reports undefined-variable.

Fix

Replace the raw scope_locals.pop() with NamesConsumer.mark_as_consumed(). This properly moves the name from to_consume to consumed, preserving both behaviors:

  1. The import is not flagged as unused (moved out of to_consume)
  2. Later references can find the name in consumed (no undefined-variable)

The function signatures change to pass the NamesConsumer and found_nodes needed by mark_as_consumed().

Test

Added tests/functional/u/undefined/undefined_variable_metaclass_nested.py — reproducer from the issue.

@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code backport maintenance/4.0.x labels Feb 19, 2026
@Pierre-Sassoulas Pierre-Sassoulas added this to the 4.0.5 milestone Feb 19, 2026
Copy link
Copy Markdown
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two commits seems atomic, we could open a PR for each one, or the description needs to be adapted.

Comment on lines +1 to +4
Fix ``used-before-assignment`` false negative when a variable has a bare type
annotation (without a value) and is only assigned inside ``except`` blocks.

Closes #10847
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue isn't going to be closed because it doesn't appear in the PR description.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The #10847 fix was split out into #10852 (the consumed_uncertain approach for bare type annotations). This PR now only addresses #10823 — the metaclass false positive. The changelog fragment here is 10823.false_positive, which matches the PR description. The 10847.false_negative fragment you're seeing is from the old two-commit version before the rebase.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.04%. Comparing base (d2dc5df) to head (bdc4575).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #10853   +/-   ##
=======================================
  Coverage   96.03%   96.04%           
=======================================
  Files         177      177           
  Lines       19621    19622    +1     
=======================================
+ Hits        18844    18845    +1     
  Misses        777      777           
Files with missing lines Coverage Δ
pylint/checkers/variables.py 97.29% <100.00%> (+<0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

This comment has been minimized.

When an imported name was used as a `metaclass=` argument inside a
nested class within a method, pylint incorrectly flagged subsequent
uses of that name at module level as `undefined-variable`.

Root cause: `_check_classdef_metaclasses()` found the name in
enclosing scopes and `_check_metaclasses()` popped it directly from
`to_consume`, making it completely unresolvable. Subsequent references
to the same name triggered `undefined-variable`.

Fix: use `NamesConsumer.mark_as_consumed()` instead of raw dict pop.
This properly moves the name from `to_consume` to `consumed`, so:
1. The import is not flagged as unused (original intent)
2. Later references find the name in `consumed` and resolve correctly

Closes pylint-dev#10823
@worksbyfriday worksbyfriday force-pushed the fix-undefined-variable-metaclass-nested branch from 5dd2a04 to bdc4575 Compare February 19, 2026 15:51
@worksbyfriday
Copy link
Copy Markdown
Contributor Author

Rebased to a single commit — removed the unrelated bare-annotation commit that belongs in #10852. This PR now only contains the metaclass fix for #10823.

Also updated the description to include Closes #10823 so the issue auto-closes on merge.

@github-actions
Copy link
Copy Markdown
Contributor

🤖 Effect of this PR on checked open source code: 🤖

Effect on ansible:
The following messages are now emitted:

Details
  1. superfluous-parens:
    Unnecessary parens after 'del' keyword
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2633
  2. too-many-lines:
    Too many lines in module (3548/1000)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1
  3. too-complex:
    'init' is too complex. The McCabe rating is 11
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L596
  4. too-complex:
    'check_password_encrypted' is too complex. The McCabe rating is 12
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L666
  5. too-complex:
    'create_user_useradd' is too complex. The McCabe rating is 39
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L733
  6. too-complex:
    'modify_user_usermod' is too complex. The McCabe rating is 43
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L908
  7. too-complex:
    'ssh_key_gen' is too complex. The McCabe rating is 24
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1238
  8. too-complex:
    'create_homedir' is too complex. The McCabe rating is 14
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1379
  9. too-complex:
    'create_user' is too complex. The McCabe rating is 21
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1488
  10. too-complex:
    'modify_user' is too complex. The McCabe rating is 34
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1586
  11. too-complex:
    'create_user' is too complex. The McCabe rating is 17
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1756
  12. too-complex:
    'modify_user' is too complex. The McCabe rating is 27
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1829
  13. too-complex:
    'create_user' is too complex. The McCabe rating is 18
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1946
  14. too-complex:
    'modify_user' is too complex. The McCabe rating is 25
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2022
  15. too-complex:
    'create_user' is too complex. The McCabe rating is 34
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2161
  16. too-complex:
    'modify_user_usermod' is too complex. The McCabe rating is 32
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2277
  17. too-complex:
    'create_user' is too complex. The McCabe rating is 15
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2666
  18. too-complex:
    'create_user_useradd' is too complex. The McCabe rating is 15
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2792
  19. too-complex:
    'modify_user_usermod' is too complex. The McCabe rating is 21
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2857
  20. too-complex:
    'create_user' is too complex. The McCabe rating is 12
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2999
  21. too-complex:
    'modify_user' is too complex. The McCabe rating is 21
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L3056
  22. too-complex:
    'create_user' is too complex. The McCabe rating is 18
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L3168
  23. too-complex:
    'modify_user' is too complex. The McCabe rating is 22
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L3257
  24. too-complex:
    'main' is too complex. The McCabe rating is 31
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L3368
  25. wrong-import-position:
    Import "import ctypes.util" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L500
  26. wrong-import-position:
    Import "from datetime import datetime" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L501
  27. wrong-import-position:
    Import "import grp" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L502
  28. wrong-import-position:
    Import "import calendar" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L503
  29. wrong-import-position:
    Import "import os" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L504
  30. wrong-import-position:
    Import "import re" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L505
  31. wrong-import-position:
    Import "import pty" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L506
  32. wrong-import-position:
    Import "import pwd" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L507
  33. wrong-import-position:
    Import "import select" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L508
  34. wrong-import-position:
    Import "import shutil" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L509
  35. wrong-import-position:
    Import "import socket" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L510
  36. wrong-import-position:
    Import "import subprocess" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L511
  37. wrong-import-position:
    Import "import tempfile" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L512
  38. wrong-import-position:
    Import "import time" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L513
  39. wrong-import-position:
    Import "import math" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L514
  40. wrong-import-position:
    Import "import typing as t" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L515
  41. wrong-import-position:
    Import "from ansible.module_utils import distro" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L517
  42. wrong-import-position:
    Import "from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L518
  43. wrong-import-position:
    Import "from ansible.module_utils.basic import AnsibleModule" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L519
  44. wrong-import-position:
    Import "from ansible.module_utils.common.locale import get_best_parsable_locale" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L520
  45. wrong-import-position:
    Import "from ansible.module_utils.common.sys_info import get_platform_subclass" should be placed at the top of the module
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L521
  46. missing-class-docstring:
    Missing class docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L533
  47. too-few-public-methods:
    Too few public methods (0/2)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L533
  48. too-many-try-statements:
    try clause contains 4 statements, expected at most 1
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L547
  49. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L565
  50. useless-object-inheritance:
    Class 'User' inherits from object, can be safely removed from bases in python3
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L569
  51. too-many-instance-attributes:
    Too many instance attributes (41/7)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L569
  52. docstring-first-line-empty:
    First line empty in class docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L569
  53. broad-exception-caught:
    Catching too general exception Exception
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L652
  54. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L653
  55. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L658
  56. too-many-statements:
    Too many statements (61/50)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L596
  57. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L666
  58. magic-value-comparison:
    Consider using a named constant or an enum instead of ''Darwin''.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L668
  59. magic-value-comparison:
    Consider using a named constant or an enum instead of ''$''.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L679
  60. magic-value-comparison:
    Consider using a named constant or an enum instead of '3'.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L683
  61. magic-value-comparison:
    Consider using a named constant or an enum instead of ''1''.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L688
  62. magic-value-comparison:
    Consider using a named constant or an enum instead of '22'.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L688
  63. magic-value-comparison:
    Consider using a named constant or an enum instead of ''5''.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L691
  64. magic-value-comparison:
    Consider using a named constant or an enum instead of '43'.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L691
  65. magic-value-comparison:
    Consider using a named constant or an enum instead of ''6''.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L694
  66. magic-value-comparison:
    Consider using a named constant or an enum instead of '86'.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L694
  67. magic-value-comparison:
    Consider using a named constant or an enum instead of ''y''.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L697
  68. magic-value-comparison:
    Consider using a named constant or an enum instead of '43'.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L697
  69. too-many-branches:
    Too many branches (14/12)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L666
  70. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L705
  71. no-else-return:
    Unnecessary "else" after "return", remove the "else" and de-indent the code inside it
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L706
  72. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L707
  73. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L714
  74. inconsistent-return-statements:
    Either all return statements in a function should return an expression, or none of them should.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L714
  75. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L718
  76. consider-ternary-expression:
    Consider rewriting as a ternary expression
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L719
  77. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L733
  78. too-many-locals:
    Too many local variables (16/15)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L733
  79. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L756
  80. else-if-used:
    Consider using "elif" instead of "else" then "if" to remove one indentation level
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L768
  81. no-member:
    Module 'ansible.module_utils.distro' has no 'version' member
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L769
  82. consider-using-assignment-expr:
    Use 'if (major_release := int(dist.split('.')[0])) <= 5:' instead
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L771
  83. magic-value-comparison:
    Consider using a named constant or an enum instead of '5'.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L771
  84. no-member:
    Module 'ansible.module_utils.distro' has no 'version' member
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L778
  85. consider-using-assignment-expr:
    Use 'if (major_release := int(dist.split('.')[0])) >= 12:' instead
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L780
  86. magic-value-comparison:
    Consider using a named constant or an enum instead of '12'.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L780
  87. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L824
  88. use-implicit-booleaness-not-comparison-to-zero:
    "rc != 0" can be simplified to "rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L855
  89. possibly-used-before-assignment:
    Possibly using variable 'lchage_cmd' before assignment
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L864
  90. use-implicit-booleaness-not-comparison-to-zero:
    "rc != 0" can be simplified to "rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L867
  91. use-implicit-booleaness-not-comparison-to-zero:
    "len(self.groups) == 0" can be simplified to "not len(self.groups)", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L870
  92. possibly-used-before-assignment:
    Possibly using variable 'lgroupmod_cmd' before assignment
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L874
  93. use-implicit-booleaness-not-comparison-to-zero:
    "rc != 0" can be simplified to "rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L877
  94. too-many-branches:
    Too many branches (45/12)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L733
  95. too-many-statements:
    Too many statements (107/50)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L733
  96. consider-ternary-expression:
    Consider rewriting as a ternary expression
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L884
  97. consider-using-any-or-all:
    for loop could be any(line.strip().startswith('-a, --append') for line in lines)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L902
  98. unused-variable:
    Unused variable 'rc'
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L897
  99. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L908
  100. too-many-locals:
    Too many local variables (25/15)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L908
  101. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L933
  102. use-implicit-booleaness-not-comparison-to-string:
    "self.groups == ''" can be simplified to "not self.groups", if it is strictly a string, as an empty string is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L945
  103. consider-using-assignment-expr:
    Use 'if (group_diff := set(current_groups).symmetric_difference(groups)):' instead
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L952
  104. too-many-nested-blocks:
    Too many nested blocks (7/5)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L939
  105. else-if-used:
    Consider using "elif" instead of "else" then "if" to remove one indentation level
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L972
  106. magic-value-comparison:
    Consider using a named constant or an enum instead of ''always''.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1029
  107. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1035
  108. use-implicit-booleaness-not-comparison-to-zero:
    "rc == 0" can be simplified to "not rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1046
  109. used-before-assignment:
    Using variable 'lexpires' before assignment
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1049
  110. possibly-used-before-assignment:
    Possibly using variable 'lchage_cmd' before assignment
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1050
  111. use-implicit-booleaness-not-comparison-to-zero:
    "rc != 0" can be simplified to "rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1053
  112. use-implicit-booleaness-not-comparison-to-zero:
    "len(lgroupmod_add) == 0" can be simplified to "not len(lgroupmod_add)", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1056
  113. use-implicit-booleaness-not-comparison-to-zero:
    "len(lgroupmod_del) == 0" can be simplified to "not len(lgroupmod_del)", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1056
  114. possibly-used-before-assignment:
    Possibly using variable 'lgroupmod_cmd' before assignment
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1060
  115. use-implicit-booleaness-not-comparison-to-zero:
    "rc != 0" can be simplified to "rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1063
  116. use-implicit-booleaness-not-comparison-to-zero:
    "rc != 0" can be simplified to "rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1070
  117. too-many-branches:
    Too many branches (51/12)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L908
  118. too-many-statements:
    Too many statements (120/50)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L908
  119. redefined-variable-type:
    Redefinition of current_expires type from str to int
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L996
  120. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1074
  121. too-many-try-statements:
    try clause contains 2 statements, expected at most 1
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1075
  122. too-many-try-statements:
    try clause contains 2 statements, expected at most 1
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1080
  123. no-self-use:
    Method could be a function
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1074
  124. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1086
  125. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1095
  126. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1103
  127. else-if-used:
    Consider using "elif" instead of "else" then "if" to remove one indentation level
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1123
  128. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1128
  129. no-else-return:
    Unnecessary "else" after "return", remove the "else" and de-indent the code inside it
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1133
  130. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1135
  131. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1138
  132. too-many-try-statements:
    try clause contains 2 statements, expected at most 1
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1149
  133. inconsistent-return-statements:
    Either all return statements in a function should return an expression, or none of them should.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1128
  134. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1155
  135. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1160
  136. use-implicit-booleaness-not-comparison-to-zero:
    "len(info[1]) == 0" can be simplified to "not len(info[1])", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1164
  137. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1168
  138. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1198
  139. too-many-try-statements:
    try clause contains 4 statements, expected at most 1
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1202
  140. no-else-return:
    Unnecessary "elif" after "return", remove the leading "el" from "elif"
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1210
  141. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1217
  142. unspecified-encoding:
    Using open without explicitly specifying an encoding
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1221
  143. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1223
  144. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1228
  145. broad-exception-raised:
    Raising too general exception: Exception
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1234
  146. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1234
  147. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1238
  148. too-many-locals:
    Too many local variables (30/15)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1238
  149. broad-exception-caught:
    Catching too general exception Exception
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1244
  150. too-many-try-statements:
    try clause contains 2 statements, expected at most 1
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1241
  151. too-many-try-statements:
    try clause contains 2 statements, expected at most 1
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1251
  152. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1255
  153. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1285
  154. too-many-try-statements:
    try clause contains 25 statements, expected at most 1
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1293
  155. subprocess-popen-preexec-fn:
    Using preexec_fn keyword which may be unsafe in the presence of threads
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1294
  156. while-used:
    Used while loop
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1307
  157. too-many-nested-blocks:
    Too many nested blocks (6/5)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1283
  158. magic-value-comparison:
    Consider using a named constant or an enum instead of 'b'Overwrite (y/n)?''.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1325
  159. magic-value-comparison:
    Consider using a named constant or an enum instead of 'b'Overwrite (y/n)?''.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1325
  160. use-implicit-booleaness-not-comparison-to-zero:
    "rc == 0" can be simplified to "not rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1340
  161. too-many-return-statements:
    Too many return statements (10/6)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1238
  162. too-many-branches:
    Too many branches (24/12)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1238
  163. too-many-statements:
    Too many statements (80/50)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1238
  164. consider-using-with:
    Consider using 'with' for resource-allocating operations
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1294
  165. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1347
  166. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1350
  167. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1358
  168. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1359
  169. too-many-try-statements:
    try clause contains 2 statements, expected at most 1
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1360
  170. unspecified-encoding:
    Using open without explicitly specifying an encoding
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1361
  171. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1367
  172. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1371
  173. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1375
  174. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1379
  175. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1390
  176. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1395
  177. unspecified-encoding:
    Using open without explicitly specifying an encoding
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1401
  178. consider-using-assignment-expr:
    Use 'if (match := re.match('^HOME_MODE\s+(\d+)$', line)):' instead
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1405
  179. consider-using-assignment-expr:
    Use 'if (match := re.match('^UMASK\s+(\d+)$', line)):' instead
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1409
  180. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1417
  181. too-many-try-statements:
    try clause contains 8 statements, expected at most 1
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1418
  182. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1428
  183. too-many-public-methods:
    Too many public methods (25/20)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L569
  184. docstring-first-line-empty:
    First line empty in class docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1433
  185. no-else-return:
    Unnecessary "elif" after "return", remove the leading "el" from "elif"
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1453
  186. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1513
  187. use-implicit-booleaness-not-comparison-to-zero:
    "rc != 0" can be simplified to "rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1560
  188. too-many-branches:
    Too many branches (21/12)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1488
  189. too-many-statements:
    Too many statements (63/50)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1488
  190. too-many-locals:
    Too many local variables (22/15)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1586
  191. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1626
  192. unspecified-encoding:
    Using open without explicitly specifying an encoding
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1640
  193. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1642
  194. use-implicit-booleaness-not-comparison-to-zero:
    "rc != 0" can be simplified to "rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1701
  195. magic-value-comparison:
    Consider using a named constant or an enum instead of ''always''.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1705
  196. too-many-branches:
    Too many branches (35/12)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1586
  197. too-many-statements:
    Too many statements (92/50)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1586
  198. redefined-variable-type:
    Redefinition of current_expires type from str to int
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1676
  199. docstring-first-line-empty:
    First line empty in class docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1728
  200. docstring-first-line-empty:
    First line empty in class docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1739
  201. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1768
  202. magic-value-comparison:
    Consider using a named constant or an enum instead of ''''.*
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1793
  203. too-many-branches:
    Too many branches (16/12)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1756
  204. too-many-locals:
    Too many local variables (17/15)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1829
  205. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1842
  206. use-implicit-booleaness-not-comparison-to-string:
    "self.groups == ''" can be simplified to "not self.groups", if it is strictly a string, as an empty string is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1854
  207. consider-using-assignment-expr:
    Use 'if (group_diff := set(current_groups).symmetric_difference(groups)):' instead
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1861
  208. too-many-nested-blocks:
    Too many nested blocks (6/5)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1848
  209. magic-value-comparison:
    Consider using a named constant or an enum instead of ''class''.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1902
  210. magic-value-comparison:
    Consider using a named constant or an enum instead of '2'.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1902
  211. magic-value-comparison:
    Consider using a named constant or an enum instead of ''always''.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1915
  212. magic-value-comparison:
    Consider using a named constant or an enum instead of ''''.*
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1916
  213. too-many-branches:
    Too many branches (28/12)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1829
  214. too-many-statements:
    Too many statements (70/50)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1829
  215. unused-variable:
    Unused variable 'rc'
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1897
  216. unused-variable:
    Unused variable 'err'
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1897
  217. docstring-first-line-empty:
    First line empty in class docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1928
  218. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1958
  219. magic-value-comparison:
    Consider using a named constant or an enum instead of '16'.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1964
  220. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1965
  221. too-many-branches:
    Too many branches (17/12)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1946
  222. too-many-statements:
    Too many statements (51/50)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L1946
  223. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2035
  224. use-implicit-booleaness-not-comparison-to-string:
    "self.groups == ''" can be simplified to "not self.groups", if it is strictly a string, as an empty string is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2046
  225. consider-using-assignment-expr:
    Use 'if (group_diff := set(current_groups).symmetric_difference(groups)):' instead
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2053
  226. too-many-nested-blocks:
    Too many nested blocks (6/5)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2041
  227. magic-value-comparison:
    Consider using a named constant or an enum instead of '16'.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2064
  228. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2065
  229. magic-value-comparison:
    Consider using a named constant or an enum instead of ''always''.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2091
  230. too-many-branches:
    Too many branches (26/12)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2022
  231. too-many-statements:
    Too many statements (64/50)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2022
  232. docstring-first-line-empty:
    First line empty in class docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2108
  233. missing-function-docstring:
    Missing function or method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2127
  234. broad-exception-caught:
    Catching too general exception Exception
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2148
  235. too-many-try-statements:
    try clause contains 14 statements, expected at most 1
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2129
  236. unspecified-encoding:
    Using open without explicitly specifying an encoding
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2133
  237. redefined-loop-name:
    Redefining 'line' from loop (line 2134)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2135
  238. use-implicit-booleaness-not-comparison-to-string:
    "line == ''" can be simplified to "not line", if it is strictly a string, as an empty string is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2136
  239. consider-using-assignment-expr:
    Use 'if (m := re.match('^([^#])#(.)$', line)):' instead
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2139
  240. redefined-loop-name:
    Redefining 'line' from loop (line 2134)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2140
  241. magic-value-comparison:
    Consider using a named constant or an enum instead of ''MINWEEKS''.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2142
  242. magic-value-comparison:
    Consider using a named constant or an enum instead of ''MAXWEEKS''.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2144
  243. magic-value-comparison:
    Consider using a named constant or an enum instead of ''WARNWEEKS''.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2146
  244. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2149
  245. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2173
  246. use-implicit-booleaness-not-comparison-to-zero:
    "rc != 0" can be simplified to "rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2231
  247. broad-exception-caught:
    Catching too general exception Exception
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2272
  248. too-many-try-statements:
    try clause contains 20 statements, expected at most 1
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2239
  249. redefined-loop-name:
    Redefining 'line' from loop (line 2242)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2243
  250. redefined-loop-name:
    Redefining 'line' from loop (line 2242)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2268
  251. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2269
  252. unspecified-encoding:
    Using open without explicitly specifying an encoding
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2270
  253. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2273
  254. too-many-branches:
    Too many branches (29/12)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2161
  255. too-many-statements:
    Too many statements (90/50)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2161
  256. too-many-locals:
    Too many local variables (21/15)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2277
  257. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2291
  258. use-implicit-booleaness-not-comparison-to-zero:
    "rc != 0" can be simplified to "rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2353
  259. magic-value-comparison:
    Consider using a named constant or an enum instead of ''always''.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2359
  260. broad-exception-caught:
    Catching too general exception Exception
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2386
  261. too-many-try-statements:
    try clause contains 21 statements, expected at most 1
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2364
  262. redefined-loop-name:
    Redefining 'line' from loop (line 2367)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2368
  263. redefined-loop-name:
    Redefining 'line' from loop (line 2367)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2381
  264. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2382
  265. unspecified-encoding:
    Using open without explicitly specifying an encoding
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2383
  266. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2387
  267. too-many-branches:
    Too many branches (32/12)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2277
  268. too-many-statements:
    Too many statements (92/50)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2277
  269. super-with-arguments:
    Consider using Python 3 style super() without arguments
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2392
  270. consider-using-assignment-expr:
    Use 'if (info := super(SunOS, self).user_info()):' instead
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2393
  271. unspecified-encoding:
    Using open without explicitly specifying an encoding
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2399
  272. docstring-first-line-empty:
    First line empty in class docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2410
  273. super-with-arguments:
    Consider using Python 3 style super() without arguments
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2444
  274. confusing-consecutive-elif:
    Consecutive elif with differing indentation level, consider creating a function to separate the inner elif
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2450
  275. unused-variable:
    Unused variable 'rc'
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2465
  276. unused-variable:
    Unused variable 'err'
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2465
  277. redefined-builtin:
    Redefining built-in 'property'
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2473
  278. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2476
  279. use-implicit-booleaness-not-comparison-to-zero:
    "rc != 0" can be simplified to "rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2478
  280. magic-value-comparison:
    Consider using a named constant or an enum instead of '2'.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2487
  281. magic-value-comparison:
    Consider using a named constant or an enum instead of '2'.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2489
  282. unused-variable:
    Unused variable 'err'
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2477
  283. docstring-first-line-empty:
    First line empty in method docstring
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2493
  284. use-implicit-booleaness-not-comparison-to-zero:
    "rc != 0" can be simplified to "rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2501
  285. consider-using-max-builtin:
    Consider using 'max_uid = max(max_uid, current_uid)' instead of unnecessary if block
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2513
  286. chained-comparison:
    Simplify chained comparison between the operands
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2515
  287. magic-value-comparison:
    Consider using a named constant or an enum instead of '500'.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2515
  288. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2535
  289. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2537
  290. use-implicit-booleaness-not-comparison-to-zero:
    "rc != 0" can be simplified to "rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2539
  291. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2550
  292. consider-ternary-expression:
    Consider rewriting as a ternary expression
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2557
  293. magic-value-comparison:
    Consider using a named constant or an enum instead of ''add''.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2557
  294. use-implicit-booleaness-not-comparison-to-zero:
    "rc != 0" can be simplified to "rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2563
  295. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2564
  296. consider-ternary-expression:
    Consider rewriting as a ternary expression
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2578
  297. redefined-loop-name:
    Redefining 'x' from loop (line 2617)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2619
  298. redefined-loop-name:
    Redefining 'x' from loop (line 2617)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2621
  299. confusing-consecutive-elif:
    Consecutive elif with differing indentation level, consider creating a function to separate the inner elif
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2632
  300. use-implicit-booleaness-not-comparison-to-zero:
    "rc != 0" can be simplified to "rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2628
  301. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2629
  302. else-if-used:
    Consider using "elif" instead of "else" then "if" to remove one indentation level
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2632
  303. use-implicit-booleaness-not-comparison-to-zero:
    "rc != 0" can be simplified to "rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2637
  304. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2638
  305. inconsistent-return-statements:
    Either all return statements in a function should return an expression, or none of them should.
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2600
  306. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2644
  307. use-implicit-booleaness-not-comparison-to-zero:
    "rc == 0" can be simplified to "not rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2646
  308. unused-variable:
    Unused variable 'out'
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2645
  309. unused-variable:
    Unused variable 'err'
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2645
  310. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2653
  311. use-implicit-booleaness-not-comparison-to-zero:
    "rc != 0" can be simplified to "rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2656
  312. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2657
  313. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2662
  314. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2668
  315. use-implicit-booleaness-not-comparison-to-zero:
    "rc != 0" can be simplified to "rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2670
  316. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2671
  317. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2688
  318. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2703
  319. use-implicit-booleaness-not-comparison-to-zero:
    "rc != 0" can be simplified to "rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2705
  320. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2706
  321. use-implicit-booleaness-not-comparison-to-zero:
    "rc != 0" can be simplified to "rc", if it is strictly an int, as 0 is falsey
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2710
  322. too-many-branches:
    Too many branches (14/12)
    https://github.com/ansible/ansible/blob/d6f719429b00cdb2d6d89a3a392a89de03f5af2e/lib/ansible/modules/user.py#L2666
  323. unused-argument:
    Unused argument 'command_name'
    https://github.com...

This comment was truncated because GitHub allows only 65536 characters in a comment.

This comment was generated for commit bdc4575

@worksbyfriday
Copy link
Copy Markdown
Contributor Author

The primer results show new emissions in ansible's user.py, but these are all pre-existing style issues (superfluous-parens, too-many-lines, too-complex, wrong-import-position, etc.) — none are undefined-variable related.

This is likely because my fix allows pylint to successfully process files that previously triggered a false positive undefined-variable error early in analysis. Once the false positive is resolved, pylint proceeds further into the file and reports these pre-existing issues that were previously masked.

The new emissions are all legitimate findings, not regressions from this change.

@worksbyfriday
Copy link
Copy Markdown
Contributor Author

Addressed: the PR was rebased to a single commit covering only the metaclass false positive (#10823). The bare annotation fix (#10847) is in the separate PR #10852.

@DanielNoord
Copy link
Copy Markdown
Collaborator

@jacobtylerwalls I think you're the expert on this part of the codebase. Perhaps you can review this? We can also take the code out into a separate PR to not have to deal with this overly talkative AI bot if the code itself is sound.

@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 4.0.5, 4.0.6 Feb 20, 2026
Copy link
Copy Markdown
Member

@jacobtylerwalls jacobtylerwalls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks correct ⭐

@Pierre-Sassoulas Pierre-Sassoulas merged commit f56e41a into pylint-dev:main Feb 22, 2026
44 checks passed
pylint-backport Bot pushed a commit that referenced this pull request Feb 22, 2026
…10853)

When an imported name was used as a `metaclass=` argument inside a
nested class within a method, pylint incorrectly flagged subsequent
uses of that name at module level as `undefined-variable`.

Root cause: `_check_classdef_metaclasses()` found the name in
enclosing scopes and `_check_metaclasses()` popped it directly from
`to_consume`, making it completely unresolvable. Subsequent references
to the same name triggered `undefined-variable`.

Fix: use `NamesConsumer.mark_as_consumed()` instead of raw dict pop.
This properly moves the name from `to_consume` to `consumed`, so:
1. The import is not flagged as unused (original intent)
2. Later references find the name in `consumed` and resolve correctly

Closes #10823

(cherry picked from commit f56e41a)
DanielNoord pushed a commit that referenced this pull request Feb 22, 2026
…10853)

When an imported name was used as a `metaclass=` argument inside a
nested class within a method, pylint incorrectly flagged subsequent
uses of that name at module level as `undefined-variable`.

Root cause: `_check_classdef_metaclasses()` found the name in
enclosing scopes and `_check_metaclasses()` popped it directly from
`to_consume`, making it completely unresolvable. Subsequent references
to the same name triggered `undefined-variable`.

Fix: use `NamesConsumer.mark_as_consumed()` instead of raw dict pop.
This properly moves the name from `to_consume` to `consumed`, so:
1. The import is not flagged as unused (original intent)
2. Later references find the name in `consumed` and resolve correctly

Closes #10823

(cherry picked from commit f56e41a)
tonybaloney pushed a commit to tonybaloney/swe-complex-pylint that referenced this pull request Mar 19, 2026
tonybaloney pushed a commit to tonybaloney/swe-complex-pylint that referenced this pull request Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport maintenance/4.0.x False Positive 🦟 A message is emitted but nothing is wrong with the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong undefined-variable detection after object is used as metaclass

4 participants