8222ea602261df413882b28944386b4e30cc8cf1,app/api/serializers.py,LabelSerializer,validate,#LabelSerializer#,21

Before Change


class LabelSerializer(serializers.ModelSerializer):

    def validate(self, attrs):
        if "prefix_key" not in attrs and "suffix_key" not in attrs:
            return super().validate(attrs)

        prefix_key = attrs["prefix_key"]

After Change


        try:
            context = self.context["request"].parser_context
            project_id = context["kwargs"]["project_id"]
            label_id = context["kwargs"].get("label_id")
        except (AttributeError, KeyError):
            pass  // unit tests don"t always have the correct context set up
        else:
            conflicting_labels = Label.objects.filter(
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 2

Instances


Project Name: chakki-works/doccano
Commit Name: 8222ea602261df413882b28944386b4e30cc8cf1
Time: 2019-10-18
Author: clewolff@microsoft.com
File Name: app/api/serializers.py
Class Name: LabelSerializer
Method Name: validate


Project Name: cve-search/cve-search
Commit Name: a2ce748d5d2156779a2ba41a260361f8d085494a
Time: 2015-12-17
Author: a@foo.be
File Name: bin/dump_last.py
Class Name:
Method Name:


Project Name: samuelclay/NewsBlur
Commit Name: f7c1df266f44c86d0e7700ed4d06dffc8ea48a04
Time: 2011-11-24
Author: samuel@ofbrooklyn.com
File Name: utils/story_functions.py
Class Name:
Method Name: pre_process_story


Project Name: GoogleCloudPlatform/healthcare
Commit Name: d2b54e1550d3ed6ba50fc991952f109e88d3a5e4
Time: 2019-07-03
Author: ruihuang@google.com
File Name: deploy/create_project.py
Class Name:
Method Name: create_deletion_lien