Pycharm warning: must implement all abstract methods
Question:
Code
class A(object):
def a(self):
raise NotImplementedError
class B(A):
def a(self):
return 7
class C(B):
pass
Why does Pycharm complain?
Problem synopsis Class C must implement all abstract methods
Answers:
It’s a reported bug – you can vote for it here: https://youtrack.jetbrains.com/issue/PY-16132
As expected, python itself recognises that instances of Class C are valid. So I suspected an bug in PyCharm.
Googling for PyCharm Bug Tracker got me to https://youtrack.jetbrains.com/issues/PY
Sure enough a ticket has been raised.
https://youtrack.jetbrains.com/issue/PY-16132
No fix yet
We can disable this warning as follows:
- Goto Preferences/Settings > Editor > Inspections
- Search for Class must implement all abstract methods
- uncheck it, then click apply
I find that warning relevant, so I would not disable it globally. You can instrument a false positive (erroneous warning) with # noqa
and it should silence the PyCharm warning:
class MySerializer(serializers.Serializer): # noqa
pass
note: I have not found a narrower warning/error code.
Code
class A(object):
def a(self):
raise NotImplementedError
class B(A):
def a(self):
return 7
class C(B):
pass
Why does Pycharm complain?
Problem synopsis Class C must implement all abstract methods
It’s a reported bug – you can vote for it here: https://youtrack.jetbrains.com/issue/PY-16132
As expected, python itself recognises that instances of Class C are valid. So I suspected an bug in PyCharm.
Googling for PyCharm Bug Tracker got me to https://youtrack.jetbrains.com/issues/PY
Sure enough a ticket has been raised.
https://youtrack.jetbrains.com/issue/PY-16132
No fix yet
We can disable this warning as follows:
- Goto Preferences/Settings > Editor > Inspections
- Search for Class must implement all abstract methods
- uncheck it, then click apply
I find that warning relevant, so I would not disable it globally. You can instrument a false positive (erroneous warning) with # noqa
and it should silence the PyCharm warning:
class MySerializer(serializers.Serializer): # noqa
pass
note: I have not found a narrower warning/error code.