diff options
author | ssolanki <sushobhitsolanki@gmail.com> | 2018-06-20 06:55:02 +0530 |
---|---|---|
committer | ssolanki <sushobhitsolanki@gmail.com> | 2018-06-20 06:55:02 +0530 |
commit | 3cf841a6a22360b28938b7e18116066a18f59532 (patch) | |
tree | e8a29c3f1f97ac27957110aba3e2f328d8f6e340 /pylint/checkers/classes.py | |
parent | aa54123f12a9e245f5914fd56c0cafd4cdf9802a (diff) | |
download | pylint-git-3cf841a6a22360b28938b7e18116066a18f59532.tar.gz |
Add new checker useless-object-inheritance.
Close #2177
Diffstat (limited to 'pylint/checkers/classes.py')
-rw-r--r-- | pylint/checkers/classes.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py index b80b05eac..e7f920880 100644 --- a/pylint/checkers/classes.py +++ b/pylint/checkers/classes.py @@ -538,10 +538,14 @@ MSGS = { 'single-string-used-for-slots', 'Used when a class __slots__ is a simple string, rather ' 'than an iterable.'), + 'R0204': ('Class %r inherits from object, can be safely removed from bases in python3', + 'useless-object-inheritance', + 'Used when a class inherit from object, which under python3 is implicit, ' + 'hence can be safely removed from bases.') } -class ScopeAccessMap(object): +class ScopeAccessMap: """Store the accessed variables per scope.""" def __init__(self): @@ -672,6 +676,9 @@ a metaclass class method.'} self.add_message('inherit-non-class', args=base.as_string(), node=node) + if ancestor.name == object.__name__: + self.add_message('useless-object-inheritance', args=node.name, node=node) + def leave_classdef(self, cnode): """close a class node: check that instance attributes are defined in __init__ and check |