Pylint error with abstract member variable
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT
Music by Eric Matyas
https://www.soundimage.org
Track title: Unforgiving Himalayas Looping
--
Chapters
00:00 Pylint Error With Abstract Member Variable
00:38 Accepted Answer Score 5
01:14 Answer 2 Score 1
01:28 Answer 3 Score 5
01:35 Thank you
--
Full question
https://stackoverflow.com/questions/1653...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pylint
#avk47
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT
Music by Eric Matyas
https://www.soundimage.org
Track title: Unforgiving Himalayas Looping
--
Chapters
00:00 Pylint Error With Abstract Member Variable
00:38 Accepted Answer Score 5
01:14 Answer 2 Score 1
01:28 Answer 3 Score 5
01:35 Thank you
--
Full question
https://stackoverflow.com/questions/1653...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pylint
#avk47
ACCEPTED ANSWER
Score 5
It is best to define name in A. Consider somebody (or you in couple weeks) wants to inherit from A and implements abstract_function:
class C(A):
def abstract_function(self):
print 'This is not an abstract class'
Now the following will raise an error even though nothing in C seems to be wrong:
c = C()
c.random_function()
If you are using self.name in A it should be defined there (and let's say it should default to something sensible saying it's not ready to use):
class A(object):
name = None
def random_function(self):
print self.name
This will make your code cleaner/less error-prone and you will also get rid of the pylint error.
ANSWER 2
Score 5
If you suffix A with Mixin, pylint will not report it
ANSWER 3
Score 1
In your case I'd could use the following option:
pylint solution.py --generated-members=name
However, it's better to consider adding name = None to the base class.