Issue
I noticed a warning in Pycharm that won't go a way in my Django project. Only think I can find is a link to it being a PyCharm bug... back in 2016
In my class:
class MySerializer(serializers.Serializer):
...
I get the following warning:
Class MySerializer must implement all abstract methods
When I do the quick fix suggested so it ends up looking like one of the following:
class MySerializer(serializers.Serializer, ABC):
...
# or
class MySerializer(serializers.Serializer, metaclass=ABCMeta):
...
# or
class MySerializer(serializers.Serializer):
# have update or create defined in serializer.
def update(self, instance, validated_data):
pass
def create(self, validated_data):
pass
But this just breaks the project and I'm not too sure what's happening here if I'm being honest or why it wants one of the above solutions to suppress the warning. Is it really a PyCharm bug or am I doing something wrong?
Solution
PyCharm has a lot of warnings. In the end, it all depends on the developers and convention they are following. For example, PyCharm will always report camelCase, but a lot of python built-in libraries use camelCase for naming - no big deal.
You didn't do anything wrong, you might implement those methods, or simply suppress the warnings:
- Go to preferences
- Write 'abstract' in search box (top-left)
- You'll see Inspections > Python > Class must implement all abstract methods
- Uncheck it
Answered By - nenadp Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.