Skip to content

Commit f4d4a52

Browse files
Mike ProsserMike Prosser
authored andcommitted
put panel_id berfore panel_uri
1 parent 92d200d commit f4d4a52

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/nipanel/_panel.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@ class Panel(ABC):
1818
"""This class allows you to connect to a panel and specify values for its controls."""
1919

2020
_stub: PythonPanelServiceStub | None
21-
_panel_uri: str
2221
_panel_id: str
22+
_panel_uri: str
2323

24-
__slots__ = ["_stub", "_panel_uri", "_panel_id", "__weakref__"]
24+
__slots__ = ["_stub", "_panel_id", "_panel_uri", "__weakref__"]
2525

26-
def __init__(self, panel_uri: str, panel_id: str) -> None:
26+
def __init__(self, panel_id: str, panel_uri: str) -> None:
2727
"""Initialize the panel."""
28-
self._panel_uri = panel_uri
2928
self._panel_id = panel_id
30-
31-
@property
32-
def panel_uri(self) -> str:
33-
"""Read-only accessor for the panel URI."""
34-
return self._panel_uri
29+
self._panel_uri = panel_uri
3530

3631
@property
3732
def panel_id(self) -> str:
3833
"""Read-only accessor for the panel ID."""
3934
return self._panel_id
4035

36+
@property
37+
def panel_uri(self) -> str:
38+
"""Read-only accessor for the panel URI."""
39+
return self._panel_uri
40+
4141
def __enter__(self) -> Self:
4242
"""Enter the runtime context related to this object."""
4343
self.connect()

src/nipanel/_streamlit_panel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ class StreamlitPanel(Panel):
66

77
__slots__ = ()
88

9-
def __init__(self, streamlit_script_uri: str, panel_id: str) -> None:
9+
def __init__(self, panel_id: str, streamlit_script_uri: str) -> None:
1010
"""Create a panel using a Streamlit script for the user interface.
1111
1212
Args:
13-
streamlit_script_uri: The file path of the Streamlit script.
1413
panel_id: A unique identifier for the panel.
14+
streamlit_script_uri: The file path of the Streamlit script.
1515
1616
Returns:
1717
A new StreamlitPanel instance.
1818
"""
19-
super().__init__(streamlit_script_uri, panel_id)
19+
super().__init__(panel_id, streamlit_script_uri)
2020

2121
def _resolve_service_location(self) -> str:
2222
# TODO: AB#3095680 - resolve to the Streamlit PythonPanelService

tests/unit/test_panel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33

44
def test___streamlit_panel___has_panel_id_and_panel_uri() -> None:
5-
panel = nipanel.StreamlitPanel("path/to/script", "my_panel")
6-
assert panel.panel_uri == "path/to/script"
5+
panel = nipanel.StreamlitPanel("my_panel", "path/to/script")
76
assert panel.panel_id == "my_panel"
7+
assert panel.panel_uri == "path/to/script"
88

99

1010
def test___connected_panel___set_value___gets_same_value() -> None:
11-
panel = nipanel.StreamlitPanel("path/to/script", "my_panel")
11+
panel = nipanel.StreamlitPanel("my_panel", "path/to/script")
1212
panel.connect()
1313

1414
panel.set_value("test_id", "test_value")
@@ -19,7 +19,7 @@ def test___connected_panel___set_value___gets_same_value() -> None:
1919

2020

2121
def test___with_panel___set_value___gets_same_value() -> None:
22-
with nipanel.StreamlitPanel("path/to/script", "my_panel") as panel:
22+
with nipanel.StreamlitPanel("my_panel", "path/to/script") as panel:
2323

2424
panel.set_value("test_id", "test_value")
2525

0 commit comments

Comments
 (0)