Skip to content

Commit

Permalink
Remove unused handler code from Runtime/Context (#1122)
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwillchen authored Dec 3, 2024
1 parent 8fabc6c commit f137433
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
14 changes: 7 additions & 7 deletions mesop/features/query_params_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def test_query_params_iter():
context = Context(get_handler=lambda x: None, states={})
context = Context(states={})
context._query_params = {
"key1": ["k1value1", "k1value2"],
"key2": ["value2"],
Expand All @@ -22,7 +22,7 @@ def test_query_params_iter():


def test_query_params_len():
context = Context(get_handler=lambda x: None, states={})
context = Context(states={})
context._query_params = {
"key1": ["value1"],
"key2": ["value2"],
Expand All @@ -33,7 +33,7 @@ def test_query_params_len():


def test_query_params_str():
context = Context(get_handler=lambda x: None, states={})
context = Context(states={})
context._query_params = {
"key1": ["value1"],
"key2": ["value2"],
Expand All @@ -44,7 +44,7 @@ def test_query_params_str():


def test_query_params_getitem():
context = Context(get_handler=lambda x: None, states={})
context = Context(states={})
context._query_params = {
"key1": ["value1"],
"key2": ["value2", "value3"],
Expand All @@ -60,7 +60,7 @@ def test_query_params_getitem():


def test_query_params_get_all():
context = Context(get_handler=lambda x: None, states={})
context = Context(states={})
context._query_params = {
"key1": ["value1"],
"key2": ["value2", "value3"],
Expand All @@ -73,7 +73,7 @@ def test_query_params_get_all():


def test_query_params_delitem():
context = Context(get_handler=lambda x: None, states={})
context = Context(states={})
context._query_params = {"key1": ["value"]}
query_params = QueryParams(lambda: context)

Expand All @@ -82,7 +82,7 @@ def test_query_params_delitem():


def test_query_params_setitem():
context = Context(get_handler=lambda x: None, states={})
context = Context(states={})
query_params = QueryParams(lambda: context)

query_params["key1"] = "value1"
Expand Down
2 changes: 0 additions & 2 deletions mesop/runtime/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
class Context:
def __init__(
self,
get_handler: Callable[[str], Handler | None],
states: dict[type[Any], object],
) -> None:
self._get_handler = get_handler
self._current_node = pb.Component()
self._previous_node: pb.Component | None = None
self._states: dict[type[Any], object] = states
Expand Down
11 changes: 1 addition & 10 deletions mesop/runtime/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def __init__(self):
self.hot_reload_counter = 0
self._path_to_page_config: dict[str, PageConfig] = {}
self.component_fns: set[Callable[..., Any]] = set()
self._handlers: dict[str, Handler] = {}
self.event_mappers: dict[Type[Any], Callable[[pb.UserEvent, Key], Any]] = {}
self._state_classes: list[type[Any]] = []
self._loading_errors: list[pb.ServerError] = []
Expand Down Expand Up @@ -96,9 +95,7 @@ def create_context(self) -> Context:
for state_class in self._state_classes:
states[state_class] = state_class()

return Context(
get_handler=self.get_handler, states=cast(dict[Any, Any], states)
)
return Context(states=cast(dict[Any, Any], states))

def wait_for_hot_reload(self):
# If hot reload is in-progress, the path may not be registered yet because the client reload
Expand Down Expand Up @@ -141,12 +138,6 @@ def get_page_config(self, *, path: str) -> PageConfig | None:
def get_path_to_page_configs(self) -> dict[str, PageConfig]:
return deepcopy(self._path_to_page_config)

def register_handler(self, handler_id: str, handler: Handler) -> None:
self._handlers[handler_id] = handler

def get_handler(self, handler_id: str) -> Handler | None:
return self._handlers[handler_id]

def register_state_class(self, state_class: Any) -> None:
self._state_classes.append(state_class)

Expand Down

0 comments on commit f137433

Please sign in to comment.