-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Control flowRequires control flow understandingRequires control flow understandingFalse 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
Pylint incorrectly tracks types:
class Xxx:
def __init__(self):
self.__val = None
@property
def get_value(self) -> int:
if self.__val is None:
self.__val = 42
return self.__val
def method(self):
return 'qwe'[:-self.get_value]
Configuration
No response
Command used
pylint a.py
Pylint output
a.py:12:22: E1130: bad operand type for unary -: NoneType (invalid-unary-operand-type)
Expected behavior
no errors
Pylint version
pylint 2.9.6
astroid 2.6.6
Python 3.9.7 (default, Aug 30 2021, 00:00:00)
[GCC 11.2.1 20210728 (Red Hat 11.2.1-1)]
OS / Environment
Fedora 34
Additional dependencies
No response
TylerYep, saroad2 and sam-s
Metadata
Metadata
Assignees
Labels
Control flowRequires control flow understandingRequires control flow understandingFalse 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