MrJ
MrJ

Reputation: 1514

Pycharm warning: must implement all abstract methods

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

Upvotes: 33

Views: 27149

Answers (4)

Raffi
Raffi

Reputation: 3396

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.

Upvotes: 19

Arun
Arun

Reputation: 896

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

Upvotes: 8

Guy Gangemi
Guy Gangemi

Reputation: 1773

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

Upvotes: 4

Mr_and_Mrs_D
Mr_and_Mrs_D

Reputation: 34086

It's a reported bug - you can vote for it here: https://youtrack.jetbrains.com/issue/PY-16132

Upvotes: 34

Related Questions