pyvis-optimized 4.4.0__tar.gz → 5.0.0__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 (54) hide show
  1. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/CHANGELOG.md +135 -19
  2. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/MANIFEST.in +0 -1
  3. {pyvis_optimized-4.4.0/pyvis_optimized.egg-info → pyvis_optimized-5.0.0}/PKG-INFO +10 -11
  4. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/README.md +7 -7
  5. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/examples/shiny_demo.py +17 -7
  6. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/examples/shiny_editor_demo.py +11 -6
  7. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/examples/shiny_simple_demo.py +2 -2
  8. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyproject.toml +4 -5
  9. pyvis_optimized-5.0.0/pyvis/_version.py +1 -0
  10. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/network.py +782 -190
  11. pyvis_optimized-5.0.0/pyvis/node.py +63 -0
  12. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/shiny/__init__.py +8 -5
  13. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/shiny/bindings.js +93 -16
  14. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/shiny/wrapper.py +160 -20
  15. pyvis_optimized-5.0.0/pyvis/templates/lib/vis-10.1.5/vis-network.min.js +78 -0
  16. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/templates/template.html +23 -12
  17. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/types/common.py +13 -2
  18. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/types/edges.py +5 -1
  19. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/types/nodes.py +4 -1
  20. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/types/physics.py +1 -1
  21. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/utils.py +2 -2
  22. pyvis_optimized-5.0.0/pyvis/vis_config.py +63 -0
  23. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0/pyvis_optimized.egg-info}/PKG-INFO +10 -11
  24. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis_optimized.egg-info/SOURCES.txt +2 -2
  25. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis_optimized.egg-info/requires.txt +1 -1
  26. pyvis_optimized-4.4.0/pyvis/_version.py +0 -1
  27. pyvis_optimized-4.4.0/pyvis/node.py +0 -35
  28. pyvis_optimized-4.4.0/pyvis/templates/lib/vis-10.1.2/vis-network.min.js +0 -78
  29. pyvis_optimized-4.4.0/pyvis/vis_config.py +0 -24
  30. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/LICENSE_BSD.txt +0 -0
  31. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/examples/edge_attribute_editing_example.py +0 -0
  32. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/notebooks/01_basics.ipynb +0 -0
  33. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/notebooks/02_networkx.ipynb +0 -0
  34. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/notebooks/03_typed_options.ipynb +0 -0
  35. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/notebooks/04_advanced.ipynb +0 -0
  36. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/notebooks/NetworkOfThrones.csv +0 -0
  37. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/notebooks/test.dot +0 -0
  38. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/__init__.py +0 -0
  39. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/edge.py +0 -0
  40. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/shiny/styles.css +0 -0
  41. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/templates/lib/bindings/utils.js +0 -0
  42. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/templates/lib/tom-select/tom-select.complete.min.js +0 -0
  43. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/templates/lib/tom-select/tom-select.css +0 -0
  44. {pyvis_optimized-4.4.0/pyvis/templates/lib/vis-10.1.2 → pyvis_optimized-5.0.0/pyvis/templates/lib/vis-10.1.5}/vis-network.min.css +0 -0
  45. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/types/__init__.py +0 -0
  46. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/types/base.py +0 -0
  47. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/types/configure.py +0 -0
  48. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/types/interaction.py +0 -0
  49. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/types/layout.py +0 -0
  50. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/types/manipulation.py +0 -0
  51. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis/types/network.py +0 -0
  52. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis_optimized.egg-info/dependency_links.txt +0 -0
  53. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/pyvis_optimized.egg-info/top_level.txt +0 -0
  54. {pyvis_optimized-4.4.0 → pyvis_optimized-5.0.0}/setup.cfg +0 -0
@@ -3,6 +3,141 @@
3
3
  All notable changes to this project are documented in this file.
4
4
 
5
5
 
6
+ ## [5.0.0] - 2026-11-18
7
+
8
+ ### Breaking Changes
9
+ - **Python 3.11+.** `requires-python` is now `>=3.11` (was `>=3.10`),
10
+ following Shiny for Python, whose next release drops 3.10. Python 3.10
11
+ users stay on pyvis-optimized 4.5.x.
12
+ - **`shiny>=1.6.4`** for the `shiny` extra (was `>=1.0`, never tested):
13
+ 1.6.4 fixes a bookmark path-traversal vulnerability, and 1.6.1 added the
14
+ `session.on_destroy()` that module cleanup uses.
15
+ - **Shiny output size is honoured.** `output_pyvis_network(height=...,
16
+ width=...)` used to be ignored once the network rendered: the output div
17
+ carried Shiny's `shiny-html-output` class, which Shiny's CSS turns into
18
+ `display: contents` (no box, so no size). The class is dropped, so the
19
+ size you ask for is the size you get. Apps that relied on the old
20
+ behaviour (network sized by its parent) may need `fill=True`.
21
+
22
+ ### Added
23
+ - `output_pyvis_network(fill=True)` is a standard Shiny fill item, so the
24
+ network grows inside `page_fillable()`, full-screen cards and sidebars.
25
+ - `theme="auto"` for `output_pyvis_network()` / `render_pyvis_network()` /
26
+ `set_theme()`: the network follows the page's Bootstrap colour mode
27
+ (`data-bs-theme` on `<html>`, as toggled by `ui.input_dark_mode()`),
28
+ including node label colours. An explicit `set_theme("light"/"dark")`
29
+ stops following; `set_theme("auto")` resumes.
30
+
31
+ ### Changed
32
+ - Shiny output: node labels follow the theme. With `theme="dark"` labels
33
+ default to `#e0e0e0` (was vis-network's dark grey `#343434`, unreadable on
34
+ the dark canvas), and `set_theme()` switches them. A label colour you set
35
+ yourself (`options.nodes.font`, at render or via `set_options()`) or per
36
+ node is never overridden.
37
+ - Bundled vis-network upgraded from 10.1.2 to 10.1.5. Picks up the upstream
38
+ fixes for escaped quotes in DOT strings (a `from_DOT()` file with a label
39
+ such as `"say \"hi\""` previously failed to render at all) and for starting
40
+ a view animation while another is pending (`fit()`/`focus()`/`move_to()`
41
+ and the search box's animated focus).
42
+
43
+ ### Security
44
+ - Remote vis-network assets now carry Subresource Integrity hashes
45
+ (`integrity` + `crossorigin` on the unpkg `<script>`/`<link>`), as the
46
+ `cdn_resources="remote"` docs already claimed. `remote_esm` covers the CSS;
47
+ its JS is loaded by an ES-module `import`, which cannot carry SRI.
48
+
49
+ ### Fixed
50
+ - `pyvis_network_server` releases its browser-side network (vis instance,
51
+ DataSets, observers) when the parent removes the module with
52
+ `await session.destroy(id)` (Shiny >= 1.6.1).
53
+ - Shiny controller commands (`ctrl.fit()`, `select_nodes()`, `add_node()`,
54
+ ...) issued while their network is being re-rendered (e.g. by the effect
55
+ that just changed its data) used to reach the old network and be lost
56
+ when the new one replaced it. They are now sent right after the outputs
57
+ carrying the new network (via `session.on_flushed()`), in the order
58
+ issued. All other commands are still sent immediately, so step-by-step
59
+ async effects show each step.
60
+ - `add_node(color=..., group=...)` warns that the colour is ignored (the
61
+ group's style applies) instead of dropping it silently, and points to
62
+ `set_group()`. `group=None` now means "no group", so the colour is kept.
63
+ - `cdn_resources="remote_esm"` rendered nothing: the main script ran as an
64
+ ES module, so strict mode threw on an undeclared loop variable and its
65
+ globals were invisible to `utils.js` (highlighting, menus). It is now a
66
+ classic script that draws once the module has loaded vis-network, and the
67
+ module exposes the full namespace, so `from_DOT()` works in this mode too.
68
+ - CSS dimensions accept a flat `calc()` expression, e.g.
69
+ `output_pyvis_network(..., height="calc(100vh - 40px)")` or
70
+ `Network(height="calc(100% - 2rem)")`. Only numbers, the existing units and
71
+ `+ - * /` are allowed inside, so the injection guard still holds. The
72
+ pattern is now shared by `Network` and the Shiny wrapper. This had made
73
+ `examples/shiny_demo.py` and `examples/shiny_editor_demo.py` crash at
74
+ startup.
75
+ - Dark-theme demos are readable: sidebar text no longer inherits bslib's
76
+ near-black sidebar colour, and `shiny_demo.py` applies its per-group colours via `set_group()`
77
+ (a node's own `color` is ignored when it has a `group`).
78
+ - `pyvis_network_ui()` no longer emits a `ShinyDeprecationWarning` on
79
+ Shiny >= 1.8: it uses `ui.output_code()`/`@render.code` instead of the
80
+ deprecated `ui.output_text_verbatim()`. Docs and examples updated likewise.
81
+
82
+ ## [4.5.0] - 2026-10-24
83
+
84
+ ### Breaking Changes
85
+ - **Duplicate node ids raise.** `add_node()` (and so `add_nodes()`/`from_nx()`)
86
+ raises `ValueError` when the id already exists, instead of warning and
87
+ ignoring the call. This reverses 4.3.0's "warn on duplicate nodes"; use
88
+ `update_node()` to change an existing node.
89
+ - **`Font(align="right")` is rejected.** vis-network honours `center`/`left`
90
+ for node labels and `horizontal`/`top`/`middle`/`bottom` for edge labels;
91
+ `NodeOptions`/`EdgeOptions` now raise `ValueError` for an align that does
92
+ nothing on that element.
93
+ - **`show()` follows `Network(notebook=...)`.** It used to default to notebook
94
+ mode regardless of the constructor. Since `Network()` defaults to
95
+ `notebook=False`, a bare `net.show("g.html")` in Jupyter now opens a browser
96
+ tab instead of returning an inline IFrame (a warning is emitted when a
97
+ Jupyter kernel is detected). Use `Network(notebook=True)` or
98
+ `show(..., notebook=True)` in notebooks.
99
+ - **`update_node(font_color=...)`** now sets the label colour instead of
100
+ storing a stray `font_color` key.
101
+
102
+ ### Added
103
+ - Graph query helpers: `get_node_ids()`, `get_edge_ids()`, `get_neighbors()`,
104
+ `get_node_degree()` and `has_edge()`.
105
+ - `CDNResource` enum in `pyvis.vis_config` (string-compatible) for
106
+ `cdn_resources`.
107
+ - `update_node()`/`update_edge()` accept a plain dict as `options=`, like
108
+ `add_node()`/`add_edge()`.
109
+
110
+ ### Changed
111
+ - **Label colour precedence is the same on every path:** a per-node
112
+ `font_color` beats a colour inside `font`, which beats
113
+ `Network(font_color=...)`. Previously the plain-kwargs path let the network
114
+ colour overwrite `font={"color": ...}`.
115
+ - A string `font` such as `"14px arial"` is kept as given instead of being
116
+ replaced by `{"color": ...}`; a `font_color` passed with it is ignored with a
117
+ warning.
118
+ - `add_nodes(options=dict)` behaves like `add_nodes(options=NodeOptions(...))`
119
+ and no longer injects the default `shape`/`color`.
120
+ - `set_group()` styling now reaches vis-network (merged into
121
+ `options.groups`), and a node with a `group` no longer has `shape="dot"`
122
+ forced on it; groups without a shape still render as dots.
123
+ - `add_legend(step_x=..., step_y=...)` is deprecated; both never had an effect.
124
+ - Edge lookups in `update_edge()`/`remove_edge()` use an index (O(1)).
125
+
126
+ ### Fixed
127
+ - `add_nodes()` options paths coerce numpy ids, deep-copy options per node and
128
+ no longer validate kwargs they then ignore.
129
+ - `font_color` inside an `options` dict is applied instead of stored as a
130
+ stray key; caller `font` and edge option dicts are no longer mutated.
131
+ - `from_nx()` drops an edge `options` attribute as it already did for nodes.
132
+ - `get_network_json()` warns for DOT networks; `generate_html()` warns when
133
+ `edge_attribute_edit` overrides `manipulation.enabled=False`.
134
+ - Legend edges draw `from` and `both` arrowheads.
135
+ - Shiny: `cluster_node_properties` is sent as vis.js `clusterNodeProperties`
136
+ (it was silently ignored) and `stabilize(iterations=0)` is honoured.
137
+ - Docs: tutorial, install guide, API reference, Shiny guide and developer docs
138
+ match the current API.
139
+ - Packaging: `notebooks/lib` re-synced with the package (tom-select 2.4.3),
140
+ conda recipes check the same files, `environment.yml` uses `shiny>=1.0`.
6
141
 
7
142
  ## [4.4.0] - 2026-09-06
8
143
 
@@ -60,25 +195,6 @@ described under 4.3.0 below ships here instead.
60
195
  - pass font_color to template and validate against CSS injection
61
196
 
62
197
  ### Fixed
63
- - preserve per-node font_color through from_nx
64
- - validate every Literal field, correct font align and arrow type sets
65
- - release listeners and registry entries when a network output is cleared or removed
66
- - null args, command queueing, container sizing, config fallback and configChange
67
- - keep numeric node ids intact in updateData, search restore and edge editing
68
- - drop unsupported cluster() and omit absent arguments instead of sending null
69
- - correct update_data and package docstrings, pin the output config attribute
70
- - resolve module namespaces for controller and standalone network commands
71
- - apply module physics toggle on a copy and only when the control is rendered
72
- - build module networks from the documented dict spec
73
- - drop dead configure plumbing and repair the edge editing example
74
- - isolate get_network_json, harden edge keys and from_nx, correct docstrings
75
- - copy local lib resources beside the HTML file and refresh stale copies
76
- - detect cycles and validate dict keys in from_nx numpy coercion
77
- - recurse into lists/dicts when coercing numpy scalars in from_nx
78
- - accept plain dict options in add_node/add_edge and apply font_color on the typed path
79
- - coerce numpy scalars in from_nx instead of dropping attributes
80
- - load the notebook template lazily in generate_html
81
- - render when physics is a bool or a node title is not a string
82
198
  - parameterize collection types, constrain Literal fields, add type guard tests, fix layout doctype
83
199
  - CI subshell bug, duplicate tests, float string conversion, addEventListener, legend validation, renames cache, recipe guards
84
200
  - add error context to write_html file operations
@@ -15,7 +15,6 @@ recursive-include notebooks *.ipynb *.csv *.dot
15
15
 
16
16
  # Exclude development files
17
17
  exclude .gitignore
18
- exclude .coveragerc
19
18
  recursive-exclude * __pycache__
20
19
  recursive-exclude * *.py[co]
21
20
  recursive-exclude * .pytest_cache
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyvis-optimized
3
- Version: 4.4.0
3
+ Version: 5.0.0
4
4
  Summary: A Python network graph visualization library - Optimized Edition
5
5
  Author-email: Jose Unpingco <datascience@westhealth.org>
6
6
  Maintainer: PyVis Contributors
@@ -17,20 +17,19 @@ Classifier: Intended Audience :: Science/Research
17
17
  Classifier: License :: OSI Approved :: BSD License
18
18
  Classifier: Operating System :: OS Independent
19
19
  Classifier: Programming Language :: Python :: 3
20
- Classifier: Programming Language :: Python :: 3.10
21
20
  Classifier: Programming Language :: Python :: 3.11
22
21
  Classifier: Programming Language :: Python :: 3.12
23
22
  Classifier: Programming Language :: Python :: 3.13
24
23
  Classifier: Topic :: Scientific/Engineering :: Visualization
25
24
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
- Requires-Python: >=3.10
25
+ Requires-Python: >=3.11
27
26
  Description-Content-Type: text/markdown
28
27
  License-File: LICENSE_BSD.txt
29
28
  Requires-Dist: jinja2>=2.9.6
30
29
  Requires-Dist: networkx>=1.11
31
30
  Requires-Dist: jsonpickle>=1.4.1
32
31
  Provides-Extra: shiny
33
- Requires-Dist: shiny>=1.0; extra == "shiny"
32
+ Requires-Dist: shiny>=1.6.4; extra == "shiny"
34
33
  Requires-Dist: htmltools; extra == "shiny"
35
34
  Provides-Extra: notebook
36
35
  Requires-Dist: ipython>=5.3.0; extra == "notebook"
@@ -69,7 +68,7 @@ PyVis is a Python library for creating and visualizing interactive network graph
69
68
 
70
69
  ## Installation
71
70
 
72
- **Requires Python >= 3.10**
71
+ **Requires Python >= 3.11**
73
72
 
74
73
  ```bash
75
74
  pip install pyvis-optimized
@@ -101,7 +100,7 @@ pip install .
101
100
  | [jinja2](https://jinja.palletsprojects.com/) >= 2.9.6 | HTML template rendering |
102
101
  | [jsonpickle](https://jsonpickle.github.io/) >= 1.4.1 | JSON serialization |
103
102
 
104
- Optional: [ipython](https://ipython.org/) >= 5.3.0 (`pyvis-optimized[notebook]`), [shiny](https://shiny.posit.co/py/) >= 1.0 and [htmltools](https://pypi.org/project/htmltools/) (`pyvis-optimized[shiny]`)
103
+ Optional: [ipython](https://ipython.org/) >= 5.3.0 (`pyvis-optimized[notebook]`), [shiny](https://shiny.posit.co/py/) >= 1.6.4 and [htmltools](https://pypi.org/project/htmltools/) (`pyvis-optimized[shiny]`)
105
104
 
106
105
  ## Quick Start
107
106
 
@@ -182,7 +181,7 @@ from pyvis.shiny import (
182
181
  app_ui = ui.page_fluid(
183
182
  output_pyvis_network("network", height="600px"),
184
183
  ui.input_action_button("fit", "Fit to View"),
185
- ui.output_text_verbatim("selected")
184
+ ui.output_code("selected")
186
185
  )
187
186
 
188
187
  def server(input, output, session):
@@ -201,7 +200,7 @@ def server(input, output, session):
201
200
  def _():
202
201
  ctrl.fit()
203
202
 
204
- @render.text
203
+ @render.code
205
204
  def selected():
206
205
  event = input.network_selectNode()
207
206
  return f"Selected: {event['nodeId']}" if event else "Click a node"
@@ -232,10 +231,10 @@ See the [Shiny Integration Guide](docs/SHINY_INTEGRATION_GUIDE.md) for complete
232
231
  ## Testing
233
232
 
234
233
  ```bash
235
- pytest pyvis/tests/ --ignore=pyvis/tests/test_html.py -v
234
+ pytest pyvis/tests/ --ignore=pyvis/tests/test_html.py --ignore=pyvis/tests/test_bindings_js.py --ignore=pyvis/tests/test_shiny_e2e.py -v
236
235
  ```
237
236
 
238
- That command runs 474 tests covering core network operations, typed options, Shiny integration, security, error handling, and regression tests for edge cases. The full suite is 495 (run `pytest --co` for the current count); the extra 21 are the Playwright browser tests in `test_html.py`, `test_bindings_js.py`, and `test_shiny_e2e.py`, which need `pip install pyvis-optimized[test]` followed by `python -m playwright install chromium`.
237
+ That command runs the non-browser tests (the same set CI's `test` job runs), covering core network operations, typed options, Shiny integration, security, error handling, and regression tests for edge cases. The three ignored files are the Playwright browser tests, which need `pip install pyvis-optimized[test]` followed by `python -m playwright install chromium`. Run `pytest --co -q` for the current counts.
239
238
 
240
239
  ## Versioning
241
240
 
@@ -260,7 +259,7 @@ pyvis/
260
259
  shiny/ # Shiny for Python integration
261
260
  wrapper.py # Controller, standalone functions, rendering
262
261
  bindings.js # JavaScript binding for vis-network
263
- tests/ # 495 tests across 29 modules (see `pytest --co` for current count)
262
+ tests/ # Test suite (see `pytest --co` for the current count)
264
263
  auto_version.py # Version bump + changelog + tag script
265
264
  ```
266
265
 
@@ -17,7 +17,7 @@ PyVis is a Python library for creating and visualizing interactive network graph
17
17
 
18
18
  ## Installation
19
19
 
20
- **Requires Python >= 3.10**
20
+ **Requires Python >= 3.11**
21
21
 
22
22
  ```bash
23
23
  pip install pyvis-optimized
@@ -49,7 +49,7 @@ pip install .
49
49
  | [jinja2](https://jinja.palletsprojects.com/) >= 2.9.6 | HTML template rendering |
50
50
  | [jsonpickle](https://jsonpickle.github.io/) >= 1.4.1 | JSON serialization |
51
51
 
52
- Optional: [ipython](https://ipython.org/) >= 5.3.0 (`pyvis-optimized[notebook]`), [shiny](https://shiny.posit.co/py/) >= 1.0 and [htmltools](https://pypi.org/project/htmltools/) (`pyvis-optimized[shiny]`)
52
+ Optional: [ipython](https://ipython.org/) >= 5.3.0 (`pyvis-optimized[notebook]`), [shiny](https://shiny.posit.co/py/) >= 1.6.4 and [htmltools](https://pypi.org/project/htmltools/) (`pyvis-optimized[shiny]`)
53
53
 
54
54
  ## Quick Start
55
55
 
@@ -130,7 +130,7 @@ from pyvis.shiny import (
130
130
  app_ui = ui.page_fluid(
131
131
  output_pyvis_network("network", height="600px"),
132
132
  ui.input_action_button("fit", "Fit to View"),
133
- ui.output_text_verbatim("selected")
133
+ ui.output_code("selected")
134
134
  )
135
135
 
136
136
  def server(input, output, session):
@@ -149,7 +149,7 @@ def server(input, output, session):
149
149
  def _():
150
150
  ctrl.fit()
151
151
 
152
- @render.text
152
+ @render.code
153
153
  def selected():
154
154
  event = input.network_selectNode()
155
155
  return f"Selected: {event['nodeId']}" if event else "Click a node"
@@ -180,10 +180,10 @@ See the [Shiny Integration Guide](docs/SHINY_INTEGRATION_GUIDE.md) for complete
180
180
  ## Testing
181
181
 
182
182
  ```bash
183
- pytest pyvis/tests/ --ignore=pyvis/tests/test_html.py -v
183
+ pytest pyvis/tests/ --ignore=pyvis/tests/test_html.py --ignore=pyvis/tests/test_bindings_js.py --ignore=pyvis/tests/test_shiny_e2e.py -v
184
184
  ```
185
185
 
186
- That command runs 474 tests covering core network operations, typed options, Shiny integration, security, error handling, and regression tests for edge cases. The full suite is 495 (run `pytest --co` for the current count); the extra 21 are the Playwright browser tests in `test_html.py`, `test_bindings_js.py`, and `test_shiny_e2e.py`, which need `pip install pyvis-optimized[test]` followed by `python -m playwright install chromium`.
186
+ That command runs the non-browser tests (the same set CI's `test` job runs), covering core network operations, typed options, Shiny integration, security, error handling, and regression tests for edge cases. The three ignored files are the Playwright browser tests, which need `pip install pyvis-optimized[test]` followed by `python -m playwright install chromium`. Run `pytest --co -q` for the current counts.
187
187
 
188
188
  ## Versioning
189
189
 
@@ -208,7 +208,7 @@ pyvis/
208
208
  shiny/ # Shiny for Python integration
209
209
  wrapper.py # Controller, standalone functions, rendering
210
210
  bindings.js # JavaScript binding for vis-network
211
- tests/ # 495 tests across 29 modules (see `pytest --co` for current count)
211
+ tests/ # Test suite (see `pytest --co` for the current count)
212
212
  auto_version.py # Version bump + changelog + tag script
213
213
  ```
214
214
 
@@ -64,6 +64,10 @@ INITIAL_EDGES = [
64
64
  {"from": 10, "to": 9, "title": "uses"},
65
65
  ]
66
66
 
67
+ # A node's own color is dropped when it has a group (the group's style wins),
68
+ # so the per-group colors above are applied as group definitions.
69
+ GROUP_COLORS = {"language": "#3776ab", "framework": "#27ae60", "library": "#e67e22"}
70
+
67
71
  # Node IDs for select dropdowns -- built from initial data
68
72
  INITIAL_NODE_CHOICES = {str(n["id"]): f'{n["label"]} ({n["id"]})' for n in INITIAL_NODES}
69
73
 
@@ -140,6 +144,8 @@ header::after, .navbar::after {
140
144
 
141
145
  /* ── Sidebar ── */
142
146
  .bslib-sidebar-layout > .sidebar {
147
+ --bslib-sidebar-fg: var(--pv-text);
148
+ color: var(--pv-text) !important;
143
149
  background: var(--pv-bg-surface) !important;
144
150
  border-right: 1px solid var(--pv-border) !important;
145
151
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3) !important;
@@ -419,7 +425,7 @@ def _tab_editor():
419
425
  ),
420
426
  ui.accordion_panel(
421
427
  "Selected Node",
422
- ui.output_text_verbatim("selected_info"),
428
+ ui.output_code("selected_info"),
423
429
  ui.input_text("edit_label", "New Label"),
424
430
  ui.input_text("edit_color", "New Color", value="#e74c3c"),
425
431
  ui.layout_columns(
@@ -522,7 +528,7 @@ def _tab_events():
522
528
  ),
523
529
  ui.accordion_panel(
524
530
  "Event Log",
525
- ui.output_text_verbatim("event_log"),
531
+ ui.output_code("event_log"),
526
532
  icon=ui.tags.i(class_="fa fa-stream"),
527
533
  ),
528
534
  id="events_acc",
@@ -562,7 +568,7 @@ def _tab_queries():
562
568
  ),
563
569
  ui.accordion_panel(
564
570
  "Response",
565
- ui.output_text_verbatim("query_response"),
571
+ ui.output_code("query_response"),
566
572
  icon=ui.tags.i(class_="fa fa-terminal"),
567
573
  ),
568
574
  id="queries_acc",
@@ -664,8 +670,11 @@ def server(input, output, session):
664
670
  @render_pyvis_network(theme="dark")
665
671
  def network():
666
672
  net = Network(heading="")
673
+ for group, color in GROUP_COLORS.items():
674
+ net.set_group(group, color=color)
667
675
  for n in INITIAL_NODES:
668
- net.add_node(n["id"], label=n["label"], color=n["color"],
676
+ # Grouped nodes take their colour from GROUP_COLORS via set_group().
677
+ net.add_node(n["id"], label=n["label"],
669
678
  shape=n["shape"], size=n["size"], group=n.get("group"))
670
679
  for e in INITIAL_EDGES:
671
680
  net.add_edge(e["from"], e["to"], title=e.get("title", ""))
@@ -676,6 +685,7 @@ def server(input, output, session):
676
685
  @reactive.effect
677
686
  @reactive.event(input.theme, ignore_init=True)
678
687
  def _switch_theme():
688
+ # Node labels follow the theme automatically.
679
689
  ctrl.set_theme(input.theme())
680
690
 
681
691
  # ── Helper: refresh node-select dropdowns ─────────────────────────
@@ -729,7 +739,7 @@ def server(input, output, session):
729
739
  def _on_deselect_node():
730
740
  selected_node_id.set(None)
731
741
 
732
- @render.text
742
+ @render.code
733
743
  def selected_info():
734
744
  ev = input.network_selectNode()
735
745
  if ev and ev.get("nodeData"):
@@ -930,7 +940,7 @@ def server(input, output, session):
930
940
  def _clear_log():
931
941
  event_log_entries.set([])
932
942
 
933
- @render.text
943
+ @render.code
934
944
  def event_log():
935
945
  entries = event_log_entries()
936
946
  if not entries:
@@ -1053,7 +1063,7 @@ def server(input, output, session):
1053
1063
  known_nodes.set(nodes_update)
1054
1064
  _refresh_selects()
1055
1065
 
1056
- @render.text
1066
+ @render.code
1057
1067
  def query_response():
1058
1068
  return last_query_response()
1059
1069
 
@@ -32,7 +32,9 @@ INITIAL_NODES = [
32
32
  {"id": 5, "label": "Epsilon", "color": "#9b59b6", "shape": "diamond", "size": 32},
33
33
  {"id": 6, "label": "Zeta", "color": "#1abc9c", "shape": "dot", "size": 22},
34
34
  {"id": 7, "label": "Eta", "color": "#e67e22", "shape": "ellipse", "size": 26},
35
- {"id": 8, "label": "Theta", "color": "#34495e", "shape": "box", "size": 28},
35
+ # Box labels sit inside the (dark) node, so keep them white in both themes.
36
+ {"id": 8, "label": "Theta", "color": "#34495e", "shape": "box", "size": 28,
37
+ "font": {"color": "#ffffff"}},
36
38
  ]
37
39
 
38
40
  INITIAL_EDGES = [
@@ -124,6 +126,8 @@ header::after, .navbar::after {
124
126
  }
125
127
 
126
128
  .bslib-sidebar-layout > .sidebar {
129
+ --bslib-sidebar-fg: var(--text);
130
+ color: var(--text) !important;
127
131
  background: var(--bg-surface) !important;
128
132
  border-right: 1px solid var(--border) !important;
129
133
  }
@@ -251,7 +255,7 @@ app_ui = ui.page_sidebar(
251
255
  # ── Edit Node ──
252
256
  ui.accordion_panel(
253
257
  "Edit Node",
254
- ui.output_text_verbatim("selected_node_info"),
258
+ ui.output_code("selected_node_info"),
255
259
  ui.input_text("edit_node_label", "Label"),
256
260
  ui.layout_columns(
257
261
  ui.input_text("edit_node_color", "Color", value="#e74c3c"),
@@ -268,7 +272,7 @@ app_ui = ui.page_sidebar(
268
272
  # ── Edit Edge ──
269
273
  ui.accordion_panel(
270
274
  "Edit Edge",
271
- ui.output_text_verbatim("selected_edge_info"),
275
+ ui.output_code("selected_edge_info"),
272
276
  ui.input_text("edit_edge_label", "Label"),
273
277
  ui.layout_columns(
274
278
  ui.input_text("edit_edge_color", "Color", value="#95a5a6"),
@@ -373,8 +377,9 @@ def server(input, output, session):
373
377
  def network():
374
378
  net = Network(heading="")
375
379
  for n in INITIAL_NODES:
380
+ extra = {"font": n["font"]} if "font" in n else {}
376
381
  net.add_node(n["id"], label=n["label"], color=n["color"],
377
- shape=n["shape"], size=n["size"])
382
+ shape=n["shape"], size=n["size"], **extra)
378
383
  for e in INITIAL_EDGES:
379
384
  net.add_edge(e["from"], e["to"], id=e["id"],
380
385
  width=e.get("width", 1), color=e.get("color"),
@@ -421,7 +426,7 @@ def server(input, output, session):
421
426
  def _on_deselect_node():
422
427
  selected_node_id.set(None)
423
428
 
424
- @render.text
429
+ @render.code
425
430
  def selected_node_info():
426
431
  ev = input.network_selectNode()
427
432
  if ev and ev.get("nodeData"):
@@ -465,7 +470,7 @@ def server(input, output, session):
465
470
  def _on_deselect_edge():
466
471
  selected_edge_id.set(None)
467
472
 
468
- @render.text
473
+ @render.code
469
474
  def selected_edge_info():
470
475
  ev = input.network_selectEdge()
471
476
  if ev and ev.get("edgeData") and not ev.get("nodeIds"):
@@ -25,7 +25,7 @@ app_ui = ui.page_fillable(
25
25
  ui.input_action_button("add", "Add Random Node", class_="btn-outline-secondary w-100"),
26
26
  ui.hr(),
27
27
  ui.h6("Last Event"),
28
- ui.output_text_verbatim("event_display"),
28
+ ui.output_code("event_display"),
29
29
  width=280,
30
30
  ),
31
31
  output_pyvis_network("network", height="100%"),
@@ -66,7 +66,7 @@ def server(input, output, session):
66
66
  "color": "#818cf8", "shape": "dot", "size": 20,
67
67
  })
68
68
 
69
- @render.text
69
+ @render.code
70
70
  def event_display():
71
71
  sel = input.network_selectNode()
72
72
  if sel:
@@ -7,7 +7,7 @@ name = "pyvis-optimized"
7
7
  dynamic = ["version"]
8
8
  description = "A Python network graph visualization library - Optimized Edition"
9
9
  readme = "README.md"
10
- requires-python = ">=3.10"
10
+ requires-python = ">=3.11"
11
11
  license = {text = "BSD"}
12
12
  authors = [
13
13
  {name = "Jose Unpingco", email = "datascience@westhealth.org"}
@@ -23,7 +23,6 @@ classifiers = [
23
23
  "License :: OSI Approved :: BSD License",
24
24
  "Operating System :: OS Independent",
25
25
  "Programming Language :: Python :: 3",
26
- "Programming Language :: Python :: 3.10",
27
26
  "Programming Language :: Python :: 3.11",
28
27
  "Programming Language :: Python :: 3.12",
29
28
  "Programming Language :: Python :: 3.13",
@@ -40,7 +39,7 @@ dependencies = [
40
39
  [project.optional-dependencies]
41
40
  # Shiny integration support
42
41
  shiny = [
43
- "shiny>=1.0",
42
+ "shiny>=1.6.4", # 1.6.4: bookmark path-traversal fix; 1.6.1: session.on_destroy
44
43
  "htmltools",
45
44
  ]
46
45
 
@@ -104,7 +103,7 @@ python_functions = "test_*"
104
103
 
105
104
  [tool.black]
106
105
  line-length = 100
107
- target-version = ['py310', 'py311', 'py312', 'py313']
106
+ target-version = ['py311', 'py312', 'py313']
108
107
  include = '\.pyi?$'
109
108
  exclude = '''
110
109
  /(
@@ -121,7 +120,7 @@ exclude = '''
121
120
  '''
122
121
 
123
122
  [tool.mypy]
124
- python_version = "3.10"
123
+ python_version = "3.11"
125
124
  warn_return_any = true
126
125
  warn_unused_configs = true
127
126
  disallow_untyped_defs = false
@@ -0,0 +1 @@
1
+ __version__ = '5.0.0'