[New-bugs-announce] [issue44122] let linter allow defining attribute outside __init__ if called in __init__
Ohad Shemesh
report at bugs.python.org
Thu May 13 06:00:26 EDT 2021
New submission from Ohad Shemesh <ohadsunny at gmail.com>:
A have a simple scenario in which I have a class with some initialized attribute that I want to be able to reset again.
In order to avoid code duplication I'd to to something like this -
class A:
def __init__(self):
self.reset()
def reset(self):
self.ls: List[datetime] = []
However this behavior makes the linter (in my case in pycharm) say "instance attribute defined outside __init__".
I think it'd be for the better if the linter allows this kind of definition if the function (i.e reset) is called in __init__.
----------
components: Parser
messages: 393568
nosy: lys.nikolaou, ohadsunny, pablogsal
priority: normal
severity: normal
status: open
title: let linter allow defining attribute outside __init__ if called in __init__
type: behavior
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44122>
_______________________________________
More information about the New-bugs-announce
mailing list