Skip to content

Commit

Permalink
Fix some linter bugs, code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gizmo385 committed Dec 19, 2024
1 parent 93c35dd commit 09ccb0b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 5 additions & 4 deletions lazy_github/lib/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ class LazyGithubContext:
# Directly assigned attributes
current_repo: Repository | None = None

def _setup_logging_handler(cls) -> None:
@classmethod
def _setup_logging_handler(cls, config: Config) -> None:
"""Setup the file logger for LazyGithub"""
try:
cls._config.core.logfile_path.parent.mkdir(parents=True, exist_ok=True)
lg_file_handler = logging.FileHandler(filename=cls._config.core.logfile_path)
config.core.logfile_path.parent.mkdir(parents=True, exist_ok=True)
lg_file_handler = logging.FileHandler(filename=config.core.logfile_path)
lg_file_handler.setFormatter(LazyGithubLogFormatter())
lg.addHandler(lg_file_handler)
except Exception:
Expand All @@ -37,7 +38,7 @@ def _setup_logging_handler(cls) -> None:
def config(cls) -> Config:
if cls._config is None:
cls._config = Config.load_config()
cls._setup_logging_handler(cls)
cls._setup_logging_handler(cls._config)
return cls._config

@classproperty
Expand Down
9 changes: 6 additions & 3 deletions lazy_github/ui/screens/new_pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ def base_ref(self) -> str:

@work
async def set_default_branch_value(self) -> None:
if LazyGithubContext.current_directory_repo == LazyGithubContext.current_repo.full_name:
if LazyGithubContext.current_directory_branch:
self.query_one("#head_ref", Input).value = LazyGithubContext.current_directory_branch
if (
LazyGithubContext.current_directory_repo
and LazyGithubContext.current_repo
and LazyGithubContext.current_directory_repo == LazyGithubContext.current_repo.full_name
):
self.query_one("#head_ref", Input).value = LazyGithubContext.current_directory_branch

async def on_mount(self) -> None:
self.fetch_branches()
Expand Down

0 comments on commit 09ccb0b

Please sign in to comment.