diff --git a/param/_utils.py b/param/_utils.py index 9c393ea1..b22cfcaa 100644 --- a/param/_utils.py +++ b/param/_utils.py @@ -663,7 +663,7 @@ def exceptions_summarized(): def _in_ipython(): try: - get_ipython() + get_ipython return True except NameError: return False diff --git a/param/parameterized.py b/param/parameterized.py index 964cc390..6d4423a9 100644 --- a/param/parameterized.py +++ b/param/parameterized.py @@ -16,6 +16,7 @@ import logging import numbers import operator +import os import re import sys import types @@ -981,6 +982,9 @@ def __getattribute__(mcs,name): return type.__getattribute__(mcs,name) +_UDPATE_PARAMETER_SIGNATURE = _in_ipython() or (os.getenv("PARAM_PARAMETER_SIGNATURE", "false").lower() in ("1" , "true")) + + class _ParameterBase(metaclass=ParameterMetaclass): """ Base Parameter class used to dynamically update the signature of all @@ -996,6 +1000,8 @@ def _modified_slots_defaults(cls): @classmethod def __init_subclass__(cls): super().__init_subclass__() + if not _UDPATE_PARAMETER_SIGNATURE: + return # _update_signature has been tested against the Parameters available # in Param, we don't want to break the Parameters created elsewhere # so wrapping this in a loose try/except. diff --git a/pixi.toml b/pixi.toml index 582c522d..b402830a 100644 --- a/pixi.toml +++ b/pixi.toml @@ -90,6 +90,9 @@ nbval = "*" [feature.doc] channels = ["pyviz"] +[feature.doc.activation.env] +PARAM_PARAMETER_SIGNATURE = "1" + [feature.doc.dependencies] graphviz = "*" nbsite = ">=0.8.4,<0.9.0" diff --git a/pyproject.toml b/pyproject.toml index 5bba09eb..6d90cff6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -120,7 +120,7 @@ asyncio_mode = "auto" asyncio_default_fixture_loop_scope="function" [tool.coverage.report] -omit = ["param/version.py"] +omit = ["param/version.py", "tests/testimports.py"] [tool.ruff] fix = true diff --git a/tests/conftest.py b/tests/conftest.py index b172cd70..3c1627b7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,7 @@ +import os + +os.environ["PARAM_PARAMETER_SIGNATURE"] = "1" # To force signature in _ParameterBase.__init_subclass__ + import param import pytest