700abc65fd2172a2c6809dd9b72cf50fc2407772,allennlp/common/from_params.py,,create_kwargs,#Any#Any#Any#,121

Before Change


    signature = inspect.signature(constructor)
    kwargs: Dict[str, Any] = {}

    parameters = dict(signature.parameters)

    // First we check for the presence of a **kwargs parameter.  If we find one, we look in the
    // superclass constructor, to see if there are arguments there that we should try to also
    // constructor.
    has_kwargs = False
    for param in parameters.values():
        if param.kind == param.VAR_KEYWORD:
            has_kwargs = True
    if has_kwargs:
        // "mro" is "method resolution order".  The first one is the current class, the next is the
        // first superclass, and so on.  Taking the first superclass should work in all cases that
        // we"re looking for here.

After Change


        // with multiple values for a single parameter (e.g., the default value gives you lazy=False
        // for a dataset reader inside **kwargs, but a particular dataset reader actually hard-codes
        // lazy=True - the superclass sees both lazy=True and lazy=False in its constructor).
        if constructed_arg is not param.default:
            kwargs[param_name] = constructed_arg

    params.assert_empty(cls.__name__)
    return kwargs

Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: allenai/allennlp
Commit Name: 700abc65fd2172a2c6809dd9b72cf50fc2407772
Time: 2020-02-03
Author: mattg@allenai.org
File Name: allennlp/common/from_params.py
Class Name:
Method Name: create_kwargs


Project Name: ray-project/ray
Commit Name: 905652cdd63ae7116fe58f74856e9caf5340345a
Time: 2020-12-12
Author: krfricke@users.noreply.github.com
File Name: python/ray/tune/integration/xgboost.py
Class Name: TuneReportCallback
Method Name: _get_report_dict


Project Name: tensorlayer/tensorlayer
Commit Name: b2e6cccd53bd6c076c32421b8c4d562a96437524
Time: 2018-03-10
Author: dhsig552@163.com
File Name: tensorlayer/layers/normalization.py
Class Name: LayerNormLayer
Method Name: __init__