e0afe32be948c78c8fc58b43ed013b88343f73ab,pytext/config/serialize.py,,_union_from_json,#Any#Any#,50

Before Change


    type_name = list(json_obj)[0]
    for subclass in subclasses:
        if type(None) != subclass and (
            type_name.lower() == _canonical_typename(subclass).lower()
        ):
            return _value_from_json(subclass, json_obj[type_name])
    raise UnionTypeError(
        f"no suitable type found for {type_name} in union {subclasses}"

After Change


        raise IncorrectTypeError(
            f"incorrect Union value {json_obj} for union {subclasses}"
        )
    subclasses_dict = {
        _canonical_typename(subclass).lower(): subclass
        for subclass in subclasses
        if type(None) != subclass
    }
    type_name = list(json_obj)[0].lower()
    if len(json_obj) == 1 and type_name in subclasses_dict:
        json_obj = next(iter(json_obj.values()))
    else:
        type_name = next(iter(subclasses_dict))
        print(
            f"can not find class type in json, trying with first class "
            + f"{type_name} in the union"
        )
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 9

Instances


Project Name: facebookresearch/pytext
Commit Name: e0afe32be948c78c8fc58b43ed013b88343f73ab
Time: 2019-05-24
Author: zsc@fb.com
File Name: pytext/config/serialize.py
Class Name:
Method Name: _union_from_json


Project Name: googledatalab/pydatalab
Commit Name: 5b48f9a9c097d26d395873044ceaa1a0b886682a
Time: 2017-06-14
Author: brandondutra@google.com
File Name: solutionbox/code_free_ml/mltoolbox/code_free_ml/analyze.py
Class Name:
Method Name: run_local_analysis


Project Name: googledatalab/pydatalab
Commit Name: 5b48f9a9c097d26d395873044ceaa1a0b886682a
Time: 2017-06-14
Author: brandondutra@google.com
File Name: solutionbox/code_free_ml/mltoolbox/code_free_ml/analyze.py
Class Name:
Method Name: run_cloud_analysis