Why does PyLint warn about no __init__?

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.


Usually you will at least use the __init__() method to initialize instance variables. If you are not doing this, then by all means turn off that warning.

Tags:

Python

Pylint