not-callable
false positive in type narrowing
#7412
Labels
Control flow
Requires control flow understanding
False Positive 🦟
A message is emitted but nothing is wrong with the code
Needs PR
This issue is accepted, sufficiently specified and now needs an implementation
Bug description
Pylint emits a false positive when calling
func()
, which shouldn't happen because of the type narrowing of theif
.I noticed that if I add to the previous code the following snippet, the error disappears:
Similarly, the error is not emitted if
func
is initialized directly in global scope.However I think this kind of inference is wrong because the above code could be a module and
func
could be set from outside and theif
is guarding that scenario 🤔Configuration
No response
Command used
Pylint output
************* Module callable callable.py:17:8: E1102: func is not callable (not-callable)
Expected behavior
pylint
shouldn't reportE1102
in this case.Pylint version
OS / Environment
MacOS 11.5.2
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: