Skip to content

Commit

Permalink
Add no_lazy import
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Sep 2, 2024
1 parent 8400206 commit c155e8e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
10 changes: 9 additions & 1 deletion panel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,15 @@


def __getattr__(name: str) -> object:
if name in _attrs:
if name == "no_lazy":
for attr in _attrs:
if attr in ("param"):
continue
mod = __getattr__(attr)
if hasattr(mod, "_attrs"):
getattr(mod._attrs, "no_lazy", None)
return name
elif name in _attrs:
import importlib
mod_name, _, attr_name = _attrs[name].partition(':')
mod = importlib.import_module(mod_name)
Expand Down
6 changes: 6 additions & 0 deletions panel/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ def _serve_init():
def __getattr__(name: str) -> object:
if name == "serve":
return _serve_init()
elif name == "no_lazy":
for attr in _attrs.items():
mod = __getattr__(attr)
if hasattr(mod, "_attrs"):
getattr(mod._attrs, "no_lazy", None)
return name
elif name in _attrs:
import importlib
mod_name, _, attr_name = _attrs[name].partition(':')
Expand Down
6 changes: 6 additions & 0 deletions panel/layout/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@
}

def __getattr__(name: str):
if name == "no_lazy":
for attr in _attrs:
mod = __getattr__(attr)
if hasattr(mod, "_attrs"):
getattr(mod._attrs, "no_lazy", None)
return name
if name in _attrs:
import importlib
mod_name, _, attr_name = _attrs[name].partition(':')
Expand Down
11 changes: 6 additions & 5 deletions panel/pane/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@
}

def __getattr__(name: str) -> object:
if name == "no_lazy":
for attr in _attrs:
mod = __getattr__(attr)
if hasattr(mod, "_attrs"):
getattr(mod._attrs, "no_lazy", None)
return name
if name in _attrs:
import importlib
mod_name, _, attr_name = _attrs[name].partition(':')
Expand Down Expand Up @@ -166,8 +172,3 @@ def __getattr__(name: str) -> object:
)

__dir__ = lambda: list(__all__)


def _import_lazy_modules():
for name in _attrs:
__getattr__(name)
3 changes: 1 addition & 2 deletions panel/pane/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from ..viewable import (
Layoutable, ServableMixin, Viewable, Viewer,
)
from . import _import_lazy_modules

if TYPE_CHECKING:
from bokeh.document import Document
Expand Down Expand Up @@ -250,7 +249,7 @@ def get_pane_type(cls, obj: Any, **kwargs) -> type['PaneBase']:
return type(obj)
descendents = []

_import_lazy_modules()
from . import no_lazy # noqa
for p in param.concrete_descendents(PaneBase).values():
if p.priority is None:
applies = True
Expand Down
8 changes: 7 additions & 1 deletion panel/widgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,13 @@


def __getattr__(name: str) -> object:
if name in _attrs:
if name == "no_lazy":
for attr in _attrs:
mod = __getattr__(attr)
if hasattr(mod, "_attrs"):
getattr(mod._attrs, "no_lazy", None)
return name
elif name in _attrs:
import importlib
mod_name, _, attr_name = _attrs[name].partition(':')
mod = importlib.import_module(mod_name)
Expand Down

0 comments on commit c155e8e

Please sign in to comment.