Open embonhomme opened 7 months ago
Thanks for the report. pylint-dev/astroid#1189 added an inference constraint for is None
, but we should add one for boolean tests.
For that reason, if you adjust the example to test if self.children_name is not None
, the false positive goes away, but that's not advisable as you'd have to test the length of the array (and thus isn't pythonic).
Same with dict. See https://github.com/pylint-dev/pylint/issues/9809
Thanks for the report. pylint-dev/astroid#1189 added an inference constraint for
is None
, but we should add one for boolean tests.For that reason, if you adjust the example to test
if self.children_name is not None
, the false positive goes away, but that's not advisable as you'd have to test the length of the array (and thus isn't pythonic).
@jacobtylerwalls Please see another example: #9809 where if foo is None:
does not successfully help to infer the optional type. This I think is a very common pattern for lazy loading attributes.
Bug description
Configuration
Command used
Pylint output
Expected behavior
No error at all
Pylint version
OS / Environment
No response
Additional dependencies