@@ -163,9 +163,7 @@ def eval_function_with_deps(function):
163
163
return function (* args , ** kwargs )
164
164
165
165
def resolve_value (value , recursive = True ):
166
- """
167
- Resolves the current value of a dynamic reference.
168
- """
166
+ """Resolves the current value of a dynamic reference."""
169
167
if not recursive :
170
168
pass
171
169
elif isinstance (value , (list , tuple )):
@@ -189,9 +187,7 @@ def resolve_value(value, recursive=True):
189
187
return value
190
188
191
189
def resolve_ref (reference , recursive = False ):
192
- """
193
- Resolves all parameters a dynamic reference depends on.
194
- """
190
+ """Resolves all parameters a dynamic reference depends on."""
195
191
if recursive :
196
192
if isinstance (reference , (list , tuple , set )):
197
193
return [r for v in reference for r in resolve_ref (v , recursive )]
@@ -250,9 +246,7 @@ def __repr__(self):
250
246
251
247
@contextmanager
252
248
def logging_level (level ):
253
- """
254
- Temporarily modify param's logging level.
255
- """
249
+ """Temporarily modify param's logging level."""
256
250
level = level .upper ()
257
251
levels = [DEBUG , INFO , WARNING , ERROR , CRITICAL , VERBOSE ]
258
252
level_names = ['DEBUG' , 'INFO' , 'WARNING' , 'ERROR' , 'CRITICAL' , 'VERBOSE' ]
@@ -468,9 +462,7 @@ def _getattr(obj, attr):
468
462
469
463
470
464
def no_instance_params (cls ):
471
- """
472
- Disables instance parameters on the class
473
- """
465
+ """Disables instance parameters on the class"""
474
466
cls ._param__private .disable_instance_params = True
475
467
return cls
476
468
@@ -527,9 +519,7 @@ def _f(self, obj, val):
527
519
528
520
529
521
def get_method_owner (method ):
530
- """
531
- Gets the instance that owns the supplied method
532
- """
522
+ """Gets the instance that owns the supplied method"""
533
523
if not inspect .ismethod (method ):
534
524
return None
535
525
if isinstance (method , partial ):
@@ -738,9 +728,7 @@ def _skip_event(*events, **kwargs):
738
728
739
729
740
730
def extract_dependencies (function ):
741
- """
742
- Extract references from a method or function that declares the references.
743
- """
731
+ """Extract references from a method or function that declares the references."""
744
732
subparameters = list (function ._dinfo ['dependencies' ])+ list (function ._dinfo ['kw' ].values ())
745
733
params = []
746
734
for p in subparameters :
@@ -893,9 +881,7 @@ class Watcher(_Watcher):
893
881
"""
894
882
895
883
def __new__ (cls_ , * args , ** kwargs ):
896
- """
897
- Allows creating Watcher without explicit precedence value.
898
- """
884
+ """Allows creating Watcher without explicit precedence value."""
899
885
values = dict (zip (cls_ ._fields , args ))
900
886
values .update (kwargs )
901
887
if 'precedence' not in values :
@@ -911,9 +897,7 @@ def __str__(self):
911
897
912
898
913
899
class ParameterMetaclass (type ):
914
- """
915
- Metaclass allowing control over creation of Parameter classes.
916
- """
900
+ """Metaclass allowing control over creation of Parameter classes."""
917
901
918
902
def __new__ (mcs , classname , bases , classdict ):
919
903
@@ -1790,9 +1774,7 @@ def compare_mapping(cls, obj1, obj2):
1790
1774
1791
1775
1792
1776
class _ParametersRestorer :
1793
- """
1794
- Context-manager to handle the reset of parameter values after an update.
1795
- """
1777
+ """Context-manager to handle the reset of parameter values after an update."""
1796
1778
1797
1779
def __init__ (self , * , parameters , restore , refs = None ):
1798
1780
self ._parameters = parameters
@@ -1889,34 +1871,26 @@ def __setstate__(self, state):
1889
1871
setattr (self , k , v )
1890
1872
1891
1873
def __getitem__ (self_ , key ):
1892
- """
1893
- Returns the class or instance parameter
1894
- """
1874
+ """Returns the class or instance parameter"""
1895
1875
inst = self_ .self
1896
1876
if inst is None :
1897
1877
return self_ ._cls_parameters [key ]
1898
1878
p = self_ .objects (instance = False )[key ]
1899
1879
return _instantiated_parameter (inst , p )
1900
1880
1901
1881
def __dir__ (self_ ):
1902
- """
1903
- Adds parameters to dir
1904
- """
1882
+ """Adds parameters to dir"""
1905
1883
return super ().__dir__ () + list (self_ ._cls_parameters )
1906
1884
1907
1885
def __iter__ (self_ ):
1908
- """
1909
- Iterates over the parameters on this object.
1910
- """
1886
+ """Iterates over the parameters on this object."""
1911
1887
yield from self_ ._cls_parameters
1912
1888
1913
1889
def __contains__ (self_ , param ):
1914
1890
return param in self_ ._cls_parameters
1915
1891
1916
1892
def __getattr__ (self_ , attr ):
1917
- """
1918
- Extends attribute access to parameter objects.
1919
- """
1893
+ """Extends attribute access to parameter objects."""
1920
1894
cls = self_ .__dict__ .get ('cls' )
1921
1895
if cls is None : # Class not initialized
1922
1896
raise AttributeError
@@ -2585,9 +2559,7 @@ def trigger(self_, *param_names):
2585
2559
self_ ._state_watchers += watchers
2586
2560
2587
2561
def _update_event_type (self_ , watcher , event , triggered ):
2588
- """
2589
- Returns an updated Event object with the type field set appropriately.
2590
- """
2562
+ """Returns an updated Event object with the type field set appropriately."""
2591
2563
if triggered :
2592
2564
event_type = 'triggered'
2593
2565
else :
@@ -2616,9 +2588,7 @@ def _execute_watcher(self, watcher, events):
2616
2588
pass
2617
2589
2618
2590
def _call_watcher (self_ , watcher , event ):
2619
- """
2620
- Invoke the given watcher appropriately given an Event object.
2621
- """
2591
+ """Invoke the given watcher appropriately given an Event object."""
2622
2592
if self_ ._TRIGGER :
2623
2593
pass
2624
2594
elif watcher .onlychanged and (not self_ ._changed (event )):
@@ -2795,9 +2765,7 @@ def deserialize_value(self_, pname, value, mode='json'):
2795
2765
return serializer .deserialize_parameter_value (self_or_cls , pname , value )
2796
2766
2797
2767
def schema (self_ , safe = False , subset = None , mode = 'json' ):
2798
- """
2799
- Returns a schema for the parameters on this Parameterized object.
2800
- """
2768
+ """Returns a schema for the parameters on this Parameterized object."""
2801
2769
self_or_cls = self_ .self_or_cls
2802
2770
if mode not in Parameter ._serializers :
2803
2771
raise ValueError (f'Mode { mode !r} not in available serialization formats { list (Parameter ._serializers .keys ())!r} ' )
@@ -3162,9 +3130,7 @@ def _watch(self_, fn, parameter_names, what='value', onlychanged=True, queued=Fa
3162
3130
return watcher
3163
3131
3164
3132
def unwatch (self_ , watcher ):
3165
- """
3166
- Remove the given Watcher object (from `watch` or `watch_values`) from this object's list.
3167
- """
3133
+ """Remove the given Watcher object (from `watch` or `watch_values`) from this object's list."""
3168
3134
try :
3169
3135
self_ ._register_watcher ('remove' , watcher , what = watcher .what )
3170
3136
except Exception :
0 commit comments