uzaxirr / logdogs

Consider decorating method with @staticmethod PYL-R0201
Performance
Major
a year agoa year old
Method doesn't use the class instance and could be converted into a static method
103            return Response(serialized_source.data, status=status.HTTP_202_ACCEPTED)
104        return Response(serialized_source.errors, status=status.HTTP_400_BAD_REQUEST)
105
106    def delete(self, request, project_id, pk):107        try:
108            required_source = Source.objects.get(pk=pk)
109        except Source.DoesNotExist:
Method doesn't use the class instance and could be converted into a static method
 84class SourceDetailedView(APIView):
 85    """Retrieve, Update and Delete on `Source` model"""
 86
 87    def get_object(self, pk): 88        try:
 89            return Source.objects.get(pk=pk)
 90        except Source.DoesNotExist:
Method doesn't use the class instance and could be converted into a static method
 72        serialized_sources = SourceSerializer(all_source, many=True)
 73        return Response(serialized_sources.data, status=status.HTTP_200_OK)
 74
 75    def post(self, request, project_id): 76        request.data["project"] = project_id
 77        serialized_source = SourceSerializer(data=request.data)
 78        if serialized_source.is_valid():
Method doesn't use the class instance and could be converted into a static method
 55class SourceView(APIView):
 56    """Create amd List on`Source` model"""
 57
 58    def get_project(self, project_id): 59        """Returns a `Project` model associated with the Source"""
 60        try:
 61            return Project.objects.get(pk=project_id)
Method doesn't use the class instance and could be converted into a static method
 46            return Response(serialized_project.data, status=status.HTTP_202_ACCEPTED)
 47        return Response(serialized_project.errors, status=status.HTTP_400_BAD_REQUEST)
 48
 49    def delete(self, request, pk): 50        required_project = Project.objects.get(pk=pk)
 51        required_project.delete()
 52        return Response(status=status.HTTP_204_NO_CONTENT)