We have numerous python classes that do not seem to need __init__
, initialising them empty is either perfectly acceptable or even preferable. PyLint seems to think this is a bad thing. Am I missing some insight into why having no __init__
is a Bad Smell? Or should I just suppress those warnings and get over it?
What are you using these classes for?
If they are just a grouping of functions that do not need to maintain any state, there is no need for an __init__()
but it would make more sense to just move all of those functions into their own module.
If they do maintain a state (they have instance variables) then you should probably have an __init__()
so that those variables can be initialized. Even if you never provide values for them when the class is created, it is generally a good idea to have them defined so that your method calls are not referencing instance variables that may or may not exist.
That being said, if you don't need an __init__()
, feel free to ignore that warning.
edit: Based on your comment, it seems like you are fine with the AttributeError you will get on referencing variables before initialization. That is a perfectly fine way to program your classes so in that case ignoring the warning from PyLint is reasonable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With