-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed as not planned
Labels
Control flowRequires control flow understandingRequires control flow understandingDuplicate 🐫Duplicate of an already existing issueDuplicate of an already existing issueFalse Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation
Description
Bug description
Minimized reproducer:
# pylint: disable=too-few-public-methods
"Module to repro false positive 'not-callable' error."""
import weakref
class Repro:
"""Class to repro false positive bug."""
def __init__(self):
self._weak = None
def repro(self):
"""Method to repro false positive bug."""
weak = getattr(self, '_weak', None)
if weak is not None:
strong = weak() # false positive error here
if strong is not None:
return strong
self._weak = weakref.ref(self)
return self._weak()
See the following line for a real-world example where this false positive is occurring: https://github.com/jab/bidict/blob/caf703e959ed4471bc391a7794411864c1d6ab9d/bidict/_base.py#L185
Configuration
No response
Command used
pylint repro.py
Pylint output
************* Module repro
repro.py:18:21: E1102: weak is not callable (not-callable)
Expected behavior
No error should be flagged here.
Pylint version
pylint 2.13.2
astroid 2.11.2
Python 3.10.2 (main, Feb 2 2022, 07:36:01) [Clang 12.0.0 (clang-1200.0.32.29)]
OS / Environment
No response
Additional dependencies
No response
meshy and CodeStix
Metadata
Metadata
Assignees
Labels
Control flowRequires control flow understandingRequires control flow understandingDuplicate 🐫Duplicate of an already existing issueDuplicate of an already existing issueFalse Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation