Skip to content

Commit

Permalink
fix: Fix typing and install issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nickderobertis committed Jul 17, 2022
1 parent 69125a8 commit a56252b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 2 additions & 0 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
"watchdog",
"typer",
"rich",
"patch",
"unidiff",
]

# Add any third party packages you use in requirements for optional features of your package here
Expand Down
15 changes: 10 additions & 5 deletions flexlate_dev/server/back_sync.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import threading
import time
from pathlib import Path
from typing import Optional, Union
from typing import Optional, Union, cast

import patch
from git import Repo
Expand Down Expand Up @@ -30,8 +30,13 @@ def commit_in_one_repo_with_another_repo_commit_message(
commit_sha: str,
) -> None:
commit_message = repo.commit(commit_sha).message
print_styled(f"Committing change: {commit_message}", INFO_STYLE)
stage_and_commit_all(other_repo, commit_message)
# Convert commit message to str if it is a bytes object
if isinstance(commit_message, bytes):
message_str = commit_message.decode("utf-8")
else:
message_str = commit_message
print_styled(f"Committing change: {message_str}", INFO_STYLE)
stage_and_commit_all(other_repo, message_str)


def _relative_path_from_diff_path(diff_path: str) -> Optional[Path]:
Expand Down Expand Up @@ -108,12 +113,12 @@ def rename():
source_path.rename(target_path)

if diff.is_added_file:
out_path = target_path
out_path = cast(Path, target_path)
content = _get_content_from_file_added_diff(diff)
out_path.parent.mkdir(parents=True, exist_ok=True)
out_path.write_text(content)
elif diff.is_removed_file:
out_path = source_path
out_path = cast(Path, source_path)
out_path.unlink()
elif is_pure_rename(diff):
rename()
Expand Down
4 changes: 2 additions & 2 deletions flexlate_dev/server/sync.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import contextlib
import os
from pathlib import Path
from typing import Callable, Optional
from typing import Callable, Iterator, Optional

from flexlate import Flexlate
from flexlate.template_data import TemplateData
Expand Down Expand Up @@ -166,7 +166,7 @@ def create_sync_server(
save: bool = False,
data: Optional[TemplateData] = None,
folder_name: Optional[str] = None,
) -> SyncServerManager:
) -> Iterator[SyncServerManager]:
event_handler = ServerEventHandler(
config,
template_path,
Expand Down

0 comments on commit a56252b

Please sign in to comment.