Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/holoviz/param into enhancem…
Browse files Browse the repository at this point in the history
…ent/rx-docs
  • Loading branch information
MarcSkovMadsen committed Nov 23, 2024
2 parents 8964a56 + 1868240 commit 3237360
Show file tree
Hide file tree
Showing 29 changed files with 121 additions and 163 deletions.
36 changes: 0 additions & 36 deletions .flake8

This file was deleted.

33 changes: 17 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
default_stages: [pre-commit]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-toml
- id: detect-private-key
- id: end-of-file-fixer
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-toml
- id: detect-private-key
- id: end-of-file-fixer
exclude: (\.min\.js$|\.svg$)
- id: trailing-whitespace
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.3
hooks:
- id: flake8
- repo: https://github.com/hoxbro/clean_notebook
rev: v0.1.10
hooks:
- id: clean-notebook
- id: ruff
exclude: \.ipynb
- repo: https://github.com/hoxbro/clean_notebook
rev: v0.1.15
hooks:
- id: clean-notebook
2 changes: 1 addition & 1 deletion doc/upgrade_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class CustomParameter(Parameter):

__slots__ = ['some_attribute']

_slot_defaults = _dict_update(Parameter._slot_defaults,
_slot_defaults = dict(Parameter._slot_defaults,
default=None, some_attribute=10
)

Expand Down
6 changes: 3 additions & 3 deletions numbergen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import param


from param import __version__ # noqa: API import
from param import __version__

class TimeAware(param.Parameterized):
"""
Expand Down Expand Up @@ -763,5 +763,5 @@ def __call__(self):
else: return val


_public = list({_k for _k,_v in locals().items() if isinstance(_v,type) and issubclass(_v,NumberGenerator)})
__all__ = _public
_public = {_k for _k,_v in locals().items() if isinstance(_v,type) and issubclass(_v,NumberGenerator)}
__all__ = ["__version__", *_public]
11 changes: 1 addition & 10 deletions param/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,7 @@ def _validate_error_prefix(parameter, attribute=None):

def _is_mutable_container(value):
"""True for mutable containers, which typically need special handling when being copied"""
return issubclass(type(value), MUTABLE_TYPES)


def _dict_update(dictionary, **kwargs):
"""
Small utility to update a copy of a dict with the provided keyword args.
"""
d = dictionary.copy()
d.update(kwargs)
return d
return isinstance(value, MUTABLE_TYPES)


def full_groupby(l, key=lambda x: x):
Expand Down
4 changes: 2 additions & 2 deletions param/ipython.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def param_docstrings(self, info, max_col_len=100, only_changed=False):
contents = []
displayed_params = []
for name in self.sort_by_precedence(params):
if only_changed and not (name in changed):
if only_changed and name not in changed:
continue
displayed_params.append((name, params[name]))

Expand Down Expand Up @@ -155,7 +155,7 @@ def _build_table(self, info, order, max_col_len=40, only_changed=False):
ordering = self.sort_by_precedence(params)
for name in ordering:
p = params[name]
if only_changed and not (name in changed):
if only_changed and name not in changed:
continue

constant = 'C' if p.constant else 'V'
Expand Down
28 changes: 8 additions & 20 deletions param/parameterized.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@
import warnings
from inspect import getfullargspec

# Allow this file to be used standalone if desired, albeit without JSON serialization
try:
from . import serializer
except ImportError:
serializer = None

from collections import defaultdict, namedtuple, OrderedDict
from functools import partial, wraps, reduce
from html import escape
Expand All @@ -39,14 +33,14 @@
from contextlib import contextmanager
from logging import DEBUG, INFO, WARNING, ERROR, CRITICAL

from . import serializer
from ._utils import (
DEFAULT_SIGNATURE,
ParamDeprecationWarning as _ParamDeprecationWarning,
ParamFutureWarning as _ParamFutureWarning,
Skip,
_deprecated,
_deprecate_positional_args,
_dict_update,
_in_ipython,
_is_auto_name,
_is_mutable_container,
Expand All @@ -67,7 +61,7 @@
try:
from .ipython import ParamPager, ipython_async_executor as async_executor
param_pager = ParamPager(metaclass=True) # Generates param description
except ImportError:
except ModuleNotFoundError:
from ._utils import async_executor
else:
from ._utils import async_executor
Expand Down Expand Up @@ -340,8 +334,6 @@ def edit_constant(parameterized):
p.constant = False
try:
yield
except:
raise
finally:
for (p, const) in zip(params, constants):
p.constant = const
Expand All @@ -359,8 +351,6 @@ def discard_events(parameterized):
list(parameterized.param._events))
try:
yield
except:
raise
finally:
parameterized.param._BATCH_WATCH = batch_watch
parameterized.param._state_watchers = watchers
Expand Down Expand Up @@ -1311,8 +1301,6 @@ def deserialize(cls, value):
return value

def schema(self, safe=False, subset=None, mode='json'):
if serializer is None:
raise ImportError('Cannot import serializer.py needed to generate schema')
if mode not in self._serializers:
raise KeyError(f'Mode {mode!r} not in available serialization formats {list(self._serializers.keys())!r}')
return self._serializers[mode].param_schema(self.__class__.__name__, self,
Expand Down Expand Up @@ -1644,7 +1632,7 @@ def __init__(self, default="0.0.0.0", allow_None=False, **kwargs):

__slots__ = ['regex']

_slot_defaults = _dict_update(Parameter._slot_defaults, default="", regex=None)
_slot_defaults = dict(Parameter._slot_defaults, default="", regex=None)

@typing.overload
def __init__(
Expand Down Expand Up @@ -1779,7 +1767,7 @@ def is_equal(cls, obj1, obj2):

@classmethod
def compare_iterator(cls, obj1, obj2):
if type(obj1) != type(obj2) or len(obj1) != len(obj2):
if type(obj1) is not type(obj2) or len(obj1) != len(obj2):
return False
for o1, o2 in zip(obj1, obj2):
if not cls.is_equal(o1, o2):
Expand All @@ -1788,7 +1776,7 @@ def compare_iterator(cls, obj1, obj2):

@classmethod
def compare_mapping(cls, obj1, obj2):
if type(obj1) != type(obj2) or len(obj1) != len(obj2): return False
if type(obj1) is not type(obj2) or len(obj1) != len(obj2): return False
for k in obj1:
if k in obj2:
if not cls.is_equal(obj1[k], obj2[k]):
Expand Down Expand Up @@ -2462,7 +2450,7 @@ def _update(self_, arg=Undefined, /, **kwargs):
raise ValueError(f"{k!r} is not a parameter of {self_.cls.__name__}")
try:
setattr(self_or_cls, k, v)
except:
except Exception:
self_._BATCH_WATCH = False
raise

Expand Down Expand Up @@ -2494,7 +2482,7 @@ def set_param(self_, *args,**kwargs):
"""
self_or_cls = self_.self_or_cls
if args:
if len(args) == 2 and not args[0] in kwargs and not kwargs:
if len(args) == 2 and args[0] not in kwargs and not kwargs:
kwargs[args[0]] = args[1]
else:
raise ValueError("Invalid positional arguments for %s.set_param" %
Expand Down Expand Up @@ -3568,7 +3556,7 @@ def __set_name(mcs, name, dict_):
"""
name_param = dict_.get("name", None)
if name_param is not None:
if not type(name_param) is String:
if type(name_param) is not String:
raise TypeError(
f"Parameterized class {name!r} cannot override "
f"the 'name' Parameter with type {type(name_param)}. "
Expand Down
Loading

0 comments on commit 3237360

Please sign in to comment.