Skip to content

Commit 592cf34

Browse files
authored
Add underscores to hide some imports (#978)
1 parent 3e587ab commit 592cf34

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

shiny/express/__init__.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from __future__ import annotations
22

3-
from ..session import Inputs, Outputs, Session
3+
# Import these with underscore names so they won't show in autocomplete from the Python
4+
# console.
5+
from ..session import Inputs as _Inputs, Outputs as _Outputs, Session as _Session
46
from ..session import _utils as _session_utils
5-
from . import app, ui
7+
from . import ui
68
from ._is_express import is_express_app
79
from ._output import output_args, suspend_display
810
from ._run import wrap_express_app
@@ -16,15 +18,14 @@
1618
"output_args",
1719
"suspend_display",
1820
"wrap_express_app",
19-
"app",
2021
"ui",
2122
"display_body",
2223
)
2324

2425
# Add types to help type checkers
25-
input: Inputs
26-
output: Outputs
27-
session: Session
26+
input: _Inputs
27+
output: _Outputs
28+
session: _Session
2829

2930

3031
# Note that users should use `from shiny.express import input` instead of `from shiny
@@ -50,8 +51,8 @@ def __init__(self):
5051

5152
from .._namespaces import Root
5253

53-
self.input = Inputs({})
54-
self.output = Outputs(cast(Session, self), Root, {}, {})
54+
self.input = _Inputs({})
55+
self.output = _Outputs(cast(_Session, self), Root, {}, {})
5556

5657
# This is needed so that Outputs don't throw an error.
5758
def _is_hidden(self, name: str) -> bool:
@@ -61,15 +62,15 @@ def _is_hidden(self, name: str) -> bool:
6162
_current_mock_session: _MockSession | None = None
6263

6364

64-
def _get_current_session_or_mock() -> Session:
65+
def _get_current_session_or_mock() -> _Session:
6566
from typing import cast
6667

6768
session = _session_utils.get_current_session()
6869
if session is None:
6970
global _current_mock_session
7071
if _current_mock_session is None:
7172
_current_mock_session = _MockSession()
72-
return cast(Session, _current_mock_session)
73+
return cast(_Session, _current_mock_session)
7374

7475
else:
7576
return session

0 commit comments

Comments
 (0)