-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
attribute-defined-outside-init warning wrongly triggered when using properties #409
Comments
I just ran into this today. Seems it hasn't gotten much attention though it's a known (albeit minor) issue. Is this just something no one has gotten around to or is there a technical limitaion which negates being able detect this condition and not show the linter warning? Actually, while I don't know what PEP has to say about it, it might be nice if there was a way to detect if a method was only ever called from init that any self. assignments not have their warnings shown either, since that line was technically executed only during object initialization. This would naturally encapsulate the property setter call, as well. |
There were few bugs in the new implementation that were masked by old implementation. These are now corrected. The tool must be aware if specific parameter were given to Config() source base class. These parameters are: digest, data, sall, stag and sgrp. The default value for these must be None or they must be left out from the parameter dictionary give to the class inherited from the Config source base class. There is an open fault in Pylint /1/. It does not see the usage of property decorator with self._parameter when the __init__ has been set with self.parameter. The later is valid syntax for the Python property decorator /2/. /1/ pylint-dev/pylint#409 /2/ https://www.python-course.eu/python3_properties.php Signed-off-by: Heikki Laaksonen <laaksonen.heikki.j@gmail.com>
I'm also hitting this. Please fix. I bet it's a difficult check though since you can call anything from anywhere and you'd have to check it all to make sure things are called from within init, etc. |
Originally reported by: James Nande (BitBucket: jnande)
Hi,
Pylint seems unable to detect Python properties properly. For instance, an attribute-defined-outside-init is triggered on the last line of the following class declaration :
Besides using a disable-msg comment, the only way I've found to circumvent this is to put a spurious self.__x = None before self.x = x.
The text was updated successfully, but these errors were encountered: