reacton 1.2.1__tar.gz → 1.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. {reacton-1.2.1 → reacton-1.2.2}/PKG-INFO +1 -1
  2. reacton-1.2.2/reacton/_version.py +1 -0
  3. {reacton-1.2.1 → reacton-1.2.2}/reacton/find.py +1 -1
  4. {reacton-1.2.1 → reacton-1.2.2}/reacton/utils.py +9 -5
  5. {reacton-1.2.1 → reacton-1.2.2}/reacton/utils_test.py +25 -1
  6. reacton-1.2.1/reacton/_version.py +0 -1
  7. {reacton-1.2.1 → reacton-1.2.2}/.gitignore +0 -0
  8. {reacton-1.2.1 → reacton-1.2.2}/LICENSE +0 -0
  9. {reacton-1.2.1 → reacton-1.2.2}/pyproject.toml +0 -0
  10. {reacton-1.2.1 → reacton-1.2.2}/react_ipywidgets/__init__.py +0 -0
  11. {reacton-1.2.1 → reacton-1.2.2}/react_ipywidgets/core.py +0 -0
  12. {reacton-1.2.1 → reacton-1.2.2}/reacton/__init__.py +0 -0
  13. {reacton-1.2.1 → reacton-1.2.2}/reacton/bqplot.py +0 -0
  14. {reacton-1.2.1 → reacton-1.2.2}/reacton/core.py +0 -0
  15. {reacton-1.2.1 → reacton-1.2.2}/reacton/core_test.py +0 -0
  16. {reacton-1.2.1 → reacton-1.2.2}/reacton/find_test.py +0 -0
  17. {reacton-1.2.1 → reacton-1.2.2}/reacton/generate.py +0 -0
  18. {reacton-1.2.1 → reacton-1.2.2}/reacton/generate_test.py +0 -0
  19. {reacton-1.2.1 → reacton-1.2.2}/reacton/ipycanvas.py +0 -0
  20. {reacton-1.2.1 → reacton-1.2.2}/reacton/ipyvue.py +0 -0
  21. {reacton-1.2.1 → reacton-1.2.2}/reacton/ipyvuetify.py +0 -0
  22. {reacton-1.2.1 → reacton-1.2.2}/reacton/ipywidgets.py +0 -0
  23. {reacton-1.2.1 → reacton-1.2.2}/reacton/logging.py +0 -0
  24. {reacton-1.2.1 → reacton-1.2.2}/reacton/patch.py +0 -0
  25. {reacton-1.2.1 → reacton-1.2.2}/reacton/patch_display.py +0 -0
  26. {reacton-1.2.1 → reacton-1.2.2}/reacton/py.typed +0 -0
  27. {reacton-1.2.1 → reacton-1.2.2}/reacton/rx.py +0 -0
  28. {reacton-1.2.1 → reacton-1.2.2}/reacton/test.vue +0 -0
  29. {reacton-1.2.1 → reacton-1.2.2}/reacton/test_rx.py +0 -0
  30. {reacton-1.2.1 → reacton-1.2.2}/reacton/work.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: reacton
3
- Version: 1.2.1
3
+ Version: 1.2.2
4
4
  Project-URL: Home, https://www.github.com/widgetti/reacton
5
5
  Project-URL: Documentation, https://reacton.solara.dev
6
6
  Project-URL: Source code, https://www.github.com/widgetti/reacton
@@ -0,0 +1 @@
1
+ __version__ = "1.2.2"
@@ -51,7 +51,7 @@ class Finder(collections.abc.Sequence, Generic[W]):
51
51
  return parent
52
52
 
53
53
  def __repr__(self):
54
- return "Finder structure:\n%r" % self._current_structure()
54
+ return "Finder structure:\n%s" % self._current_structure()
55
55
 
56
56
  def _reexecute_find(self):
57
57
  finder = self._root()
@@ -1,5 +1,6 @@
1
1
  import functools
2
2
  import inspect
3
+ import sys
3
4
  import types
4
5
  from typing import Callable, TypeVar, cast
5
6
 
@@ -71,12 +72,14 @@ def equals(a, b):
71
72
 
72
73
 
73
74
  def import_item(name: str):
74
- """Import an object by name like pandas.DataFrame"""
75
- parts = name.rsplit(".", 2)
75
+ """Import an object by name like pandas.DataFrame if the module is imported, else return None"""
76
+ parts = name.rsplit(".", 1)
76
77
  if len(parts) == 1:
77
- return __import__(name)
78
+ return sys.modules.get(name)
78
79
  else:
79
- module = __import__(".".join(parts[:-1]), fromlist=[parts[-1]])
80
+ module = sys.modules.get(parts[0])
81
+ if module is None:
82
+ return None
80
83
  return getattr(module, parts[-1])
81
84
 
82
85
 
@@ -85,8 +88,9 @@ def isinstance_lazy(value, types):
85
88
  types = [types]
86
89
  types = [import_item(t) if isinstance(t, str) else t for t in types]
87
90
  for type in types:
88
- if isinstance(value, type):
91
+ if type is not None and isinstance(value, type):
89
92
  return True
93
+ return False
90
94
 
91
95
 
92
96
  def dataframe_fingerprint(df):
@@ -1,8 +1,10 @@
1
+ import sys
2
+
1
3
  import pytest
2
4
 
3
5
  import reacton.ipywidgets as w
4
6
 
5
- from .utils import equals
7
+ from .utils import equals, import_item, isinstance_lazy
6
8
 
7
9
 
8
10
  class NeverEquals:
@@ -82,3 +84,25 @@ def test_equals():
82
84
  assert equals(el1.kwargs, el2.kwargs)
83
85
  assert equals(el1, el2)
84
86
  assert not equals(el1, el3)
87
+
88
+
89
+ def test_import_item():
90
+ assert import_item("sys.modules") is sys.modules
91
+ assert import_item("sys") is sys
92
+ assert import_item("doesnotexist") is None
93
+ assert import_item("doesnotexist.a") is None
94
+ assert import_item("doesnotexist.a.b") is None
95
+
96
+
97
+ def test_isinstance_lazy():
98
+ assert isinstance_lazy(1, int)
99
+ assert isinstance_lazy(1, (int, "does.not.exist"))
100
+ assert not isinstance_lazy(1, "does.not.exist")
101
+ import pandas
102
+
103
+ sys.modules.pop("pandas", None)
104
+ assert not isinstance_lazy(1, "pandas.DataFrame")
105
+ import pandas as pd
106
+
107
+ df = pd.DataFrame()
108
+ assert isinstance_lazy(df, "pandas.DataFrame")
@@ -1 +0,0 @@
1
- __version__ = "1.2.1"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes