Suppress WARNING:param.Test100007: Setting non-parameter attribute

import param

class Test1(param.Parameterized):
    input_dict = param.Dict(default=None, allow_None=False)

    def __init__(self, **kwds):
        super().__init__(**kwds)

Is there a way to suppress:

WARNING:param.Test100007: Setting non-parameter attribute something=['something'] using a mechanism intended only for parameters

when doing
Test1(something=['something'])

Sure @ahuang11

What triggers the warning is that something is provided to super().__init__ in the kwds dict.

You need to avoid that. There are two approaches. 1) Remove something from kwds before super 2) never add it to kwds. The two approaches are shown below.

import param

class Test1(param.Parameterized):
    input_dict = param.Dict(default=None, allow_None=False)

    def __init__(self, something_else=None, **kwds):
        self.something = kwds.pop("something", None)
        
        super().__init__(**kwds)

        self.something_else=something_else

Test1()
Test1(something=['something'])
Test1(something_else=['something_else'])
Test1(something=['something'], something_else=['something_else'])

image

2 Likes

Thanks so much. Method 1 is what I need since I am expecting multiple unknown keywords

1 Like