I have a python class that inherit from collections.Counter
:
class Analyzer(collections.Counter):
pass
When I use pylint on this code, its answer is:
W: Method 'fromkeys' is abstract in class 'Counter' but is not overridden (abstract-method)
I checked the implementation of collections.Counter
on my machine, and effectively, this method is not implemented (and a comment helps to understand why):
class Counter(dict):
...
@classmethod
def fromkeys(cls, iterable, v=None):
# There is no equivalent method for counters because setting v=1
# means that no element can have a count greater than one.
raise NotImplementedError(
'Counter.fromkeys() is undefined. Use Counter(iterable) instead.')
However, I don't really know how to implement this method, if Counter
itself does not…
What is the way to solve this warning in this situation?