Skip to content

Commit c14fba2

Browse files
MarcSkovMadsenhoxbro
authored andcommitted
ruff D200 rule
1 parent 0d73ff5 commit c14fba2

35 files changed

+86
-259
lines changed

numbergen/__init__.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
Callable objects that generate numbers according to different distributions.
3-
"""
1+
"""Callable objects that generate numbers according to different distributions."""
42

53
import random
64
import operator
@@ -241,9 +239,7 @@ def _rational(self, val):
241239

242240

243241
def __getstate__(self):
244-
"""
245-
Avoid Hashlib.md5 TypeError in deepcopy (hashlib issue)
246-
"""
242+
"""Avoid Hashlib.md5 TypeError in deepcopy (hashlib issue)"""
247243
d = self.__dict__.copy()
248244
d.pop('_digest')
249245
d.pop('_hash_struct')
@@ -374,9 +370,7 @@ def _initialize_random_state(self, seed=None, shared=True, name=None):
374370

375371

376372
def _verify_constrained_hash(self):
377-
"""
378-
Warn if the object name is not explicitly set.
379-
"""
373+
"""Warn if the object name is not explicitly set."""
380374
changed_params = self.param.values(onlychanged=True)
381375
if self.time_dependent and ('name' not in changed_params):
382376
self.param.log(param.WARNING, "Default object name used to set the seed: "
@@ -575,9 +569,7 @@ def __call__(self):
575569

576570

577571
class ScaledTime(NumberGenerator, TimeDependent):
578-
"""
579-
The current time multiplied by some conversion factor.
580-
"""
572+
"""The current time multiplied by some conversion factor."""
581573

582574
factor = param.Number(default=1.0, doc="""
583575
The factor to be multiplied by the current time value.""")

param/_utils.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ class ParamFutureWarning(ParamWarning, FutureWarning):
6262
"""
6363

6464
class Skip(Exception):
65-
"""
66-
Exception that allows skipping an update when resolving a reference.
67-
"""
65+
"""Exception that allows skipping an update when resolving a reference."""
6866

6967
def _deprecated(extra_msg="", warning_cat=ParamDeprecationWarning):
7068
def decorator(func):
@@ -208,19 +206,15 @@ def _is_mutable_container(value):
208206

209207

210208
def full_groupby(l, key=lambda x: x):
211-
"""
212-
Groupby implementation which does not require a prior sort
213-
"""
209+
"""Groupby implementation which does not require a prior sort"""
214210
d = defaultdict(list)
215211
for item in l:
216212
d[key(item)].append(item)
217213
return d.items()
218214

219215

220216
def iscoroutinefunction(function):
221-
"""
222-
Whether the function is an asynchronous generator or a coroutine.
223-
"""
217+
"""Whether the function is an asynchronous generator or a coroutine."""
224218
# Partial unwrapping not required starting from Python 3.11.0
225219
# See https://github.com/holoviz/param/pull/894#issuecomment-1867084447
226220
while isinstance(function, functools.partial):
@@ -231,9 +225,7 @@ def iscoroutinefunction(function):
231225
)
232226

233227
async def _to_thread(func, /, *args, **kwargs):
234-
"""
235-
Polyfill for asyncio.to_thread in Python < 3.9
236-
"""
228+
"""Polyfill for asyncio.to_thread in Python < 3.9"""
237229
loop = asyncio.get_running_loop()
238230
ctx = contextvars.copy_context()
239231
func_call = functools.partial(ctx.run, func, *args, **kwargs)
@@ -289,9 +281,7 @@ def flatten(line):
289281
def accept_arguments(
290282
f: Callable[Concatenate[CallableT, P], R]
291283
) -> Callable[P, Callable[[CallableT], R]]:
292-
"""
293-
Decorator for decorators that accept arguments
294-
"""
284+
"""Decorator for decorators that accept arguments"""
295285
@functools.wraps(f)
296286
def _f(*args: P.args, **kwargs: P.kwargs) -> Callable[[CallableT], R]:
297287
return lambda actual_f: f(actual_f, *args, **kwargs)

param/ipython.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,7 @@ def params(self, parameter_s='', namespaces=None):
350350

351351

352352
class IPythonDisplay:
353-
"""
354-
Reactive display handler that updates the output.
355-
"""
353+
"""Reactive display handler that updates the output."""
356354

357355
enabled = True
358356

param/parameterized.py

Lines changed: 17 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,7 @@ def eval_function_with_deps(function):
163163
return function(*args, **kwargs)
164164

165165
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."""
169167
if not recursive:
170168
pass
171169
elif isinstance(value, (list, tuple)):
@@ -189,9 +187,7 @@ def resolve_value(value, recursive=True):
189187
return value
190188

191189
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."""
195191
if recursive:
196192
if isinstance(reference, (list, tuple, set)):
197193
return [r for v in reference for r in resolve_ref(v, recursive)]
@@ -250,9 +246,7 @@ def __repr__(self):
250246

251247
@contextmanager
252248
def logging_level(level):
253-
"""
254-
Temporarily modify param's logging level.
255-
"""
249+
"""Temporarily modify param's logging level."""
256250
level = level.upper()
257251
levels = [DEBUG, INFO, WARNING, ERROR, CRITICAL, VERBOSE]
258252
level_names = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL', 'VERBOSE']
@@ -468,9 +462,7 @@ def _getattr(obj, attr):
468462

469463

470464
def no_instance_params(cls):
471-
"""
472-
Disables instance parameters on the class
473-
"""
465+
"""Disables instance parameters on the class"""
474466
cls._param__private.disable_instance_params = True
475467
return cls
476468

@@ -527,9 +519,7 @@ def _f(self, obj, val):
527519

528520

529521
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"""
533523
if not inspect.ismethod(method):
534524
return None
535525
if isinstance(method, partial):
@@ -738,9 +728,7 @@ def _skip_event(*events, **kwargs):
738728

739729

740730
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."""
744732
subparameters = list(function._dinfo['dependencies'])+list(function._dinfo['kw'].values())
745733
params = []
746734
for p in subparameters:
@@ -893,9 +881,7 @@ class Watcher(_Watcher):
893881
"""
894882

895883
def __new__(cls_, *args, **kwargs):
896-
"""
897-
Allows creating Watcher without explicit precedence value.
898-
"""
884+
"""Allows creating Watcher without explicit precedence value."""
899885
values = dict(zip(cls_._fields, args))
900886
values.update(kwargs)
901887
if 'precedence' not in values:
@@ -911,9 +897,7 @@ def __str__(self):
911897

912898

913899
class ParameterMetaclass(type):
914-
"""
915-
Metaclass allowing control over creation of Parameter classes.
916-
"""
900+
"""Metaclass allowing control over creation of Parameter classes."""
917901

918902
def __new__(mcs, classname, bases, classdict):
919903

@@ -1790,9 +1774,7 @@ def compare_mapping(cls, obj1, obj2):
17901774

17911775

17921776
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."""
17961778

17971779
def __init__(self, *, parameters, restore, refs=None):
17981780
self._parameters = parameters
@@ -1889,34 +1871,26 @@ def __setstate__(self, state):
18891871
setattr(self, k, v)
18901872

18911873
def __getitem__(self_, key):
1892-
"""
1893-
Returns the class or instance parameter
1894-
"""
1874+
"""Returns the class or instance parameter"""
18951875
inst = self_.self
18961876
if inst is None:
18971877
return self_._cls_parameters[key]
18981878
p = self_.objects(instance=False)[key]
18991879
return _instantiated_parameter(inst, p)
19001880

19011881
def __dir__(self_):
1902-
"""
1903-
Adds parameters to dir
1904-
"""
1882+
"""Adds parameters to dir"""
19051883
return super().__dir__() + list(self_._cls_parameters)
19061884

19071885
def __iter__(self_):
1908-
"""
1909-
Iterates over the parameters on this object.
1910-
"""
1886+
"""Iterates over the parameters on this object."""
19111887
yield from self_._cls_parameters
19121888

19131889
def __contains__(self_, param):
19141890
return param in self_._cls_parameters
19151891

19161892
def __getattr__(self_, attr):
1917-
"""
1918-
Extends attribute access to parameter objects.
1919-
"""
1893+
"""Extends attribute access to parameter objects."""
19201894
cls = self_.__dict__.get('cls')
19211895
if cls is None: # Class not initialized
19221896
raise AttributeError
@@ -2585,9 +2559,7 @@ def trigger(self_, *param_names):
25852559
self_._state_watchers += watchers
25862560

25872561
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."""
25912563
if triggered:
25922564
event_type = 'triggered'
25932565
else:
@@ -2616,9 +2588,7 @@ def _execute_watcher(self, watcher, events):
26162588
pass
26172589

26182590
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."""
26222592
if self_._TRIGGER:
26232593
pass
26242594
elif watcher.onlychanged and (not self_._changed(event)):
@@ -2795,9 +2765,7 @@ def deserialize_value(self_, pname, value, mode='json'):
27952765
return serializer.deserialize_parameter_value(self_or_cls, pname, value)
27962766

27972767
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."""
28012769
self_or_cls = self_.self_or_cls
28022770
if mode not in Parameter._serializers:
28032771
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
31623130
return watcher
31633131

31643132
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."""
31683134
try:
31693135
self_._register_watcher('remove', watcher, what=watcher.what)
31703136
except Exception:

0 commit comments

Comments
 (0)