Skip to content

Commit

Permalink
minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Swen Wenzel committed Nov 5, 2019
1 parent 219fec9 commit 874158a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion esque/cli/commands.py
Expand Up @@ -141,7 +141,7 @@ def edit_topic(state: State, topic_name: str):
controller = state.cluster.topic_controller
topic = state.cluster.topic_controller.get_cluster_topic(topic_name)
try:
new_conf = edit_yaml(topic.to_yaml(only_editable=True), validator=validate_editable_topic_config)
_, new_conf = edit_yaml(topic.to_yaml(only_editable=True), validator=validate_editable_topic_config)
except EditCanceled:
click.echo("Edit canceled")
return
Expand Down
6 changes: 3 additions & 3 deletions esque/cli/helpers.py
@@ -1,6 +1,6 @@
import pathlib
import shutil
from typing import Callable, Dict, Optional, Union
from typing import Callable, Dict, Optional, Union, Tuple

import click
import yaml
Expand Down Expand Up @@ -42,7 +42,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
shutil.rmtree(self._dir)


def edit_yaml(yaml_str: str, validator: Optional[Callable[[Dict], None]] = None) -> Dict:
def edit_yaml(yaml_str: str, validator: Optional[Callable[[Dict], None]] = None) -> Tuple[str, Dict]:
while True:
yaml_str: Optional[str] = click.edit(yaml_str, extension=".yaml")

Expand All @@ -57,7 +57,7 @@ def edit_yaml(yaml_str: str, validator: Optional[Callable[[Dict], None]] = None)
_handle_edit_exception(e)
else:
break
return config_data
return yaml_str, config_data


def _handle_edit_exception(e: Union[ScannerError, YamaleValidationException]) -> None:
Expand Down
2 changes: 1 addition & 1 deletion esque/resources/topic.py
Expand Up @@ -121,7 +121,7 @@ def __repr__(self):
return f"<TopicDiff[{str(self._diffs)}>"


def copy_to_local(topic):
def copy_to_local(topic: "Topic") -> "Topic":
return Topic(topic.name, topic.num_partitions, topic.replication_factor, topic.config)


Expand Down

0 comments on commit 874158a

Please sign in to comment.