A class is inherited from object
by default, so explicitly inheriting from object is redundant. Removing it keeps the code simpler.
A technical reason for inheriting from object
could be when writing code that is compatibility with Python 2.7: Python 3 classes inherits from object
by default, but Python 2.7 classes do not.
Note though that Python 2.7 has already reached "End Of Life" and is no longer supported by the Python Software Foundation. For this reason your code might not need to support Python 2.7 either.
Moreover, it takes more than inheriting classes from object to make your codebase backwards compatible with Python 2.7: you must not use any new feature of Python 3...ever. That's some serious dedication to a dead language.
Given that all three of these class definitions are completely equivalent:
Why not choose the easiest to both read and write (the first one)
If our GitHub code review bot spots this issue in your pull request it gives this advice:
1 | + | class FooBarClass(object): |
A class is inherited from object
by default, so explicitly inheriting from object is redundant. Removing it keeps the code simpler.
- | class FooBarClass(object): |
+ | class FooBarClass: |
2 | + | pass |