Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pathlib.Path for path functionality #217

Merged
merged 6 commits into from
Nov 19, 2023
Merged

Use pathlib.Path for path functionality #217

merged 6 commits into from
Nov 19, 2023

Conversation

patrit
Copy link
Contributor

@patrit patrit commented Nov 18, 2023

Get rid of the last part of dedicated file based rule exclusion from the migration to ruff.
It might be a good idea to use Path class in a future patch more consistently throughout the code.

Copy link
Member

@christiansiegel christiansiegel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍
(The mocking was already ugly before. can be addressed later)

@@ -35,7 +35,7 @@ def finalize(self) -> None:

def get_full_file_path(self, relative_path: str) -> str:
repo = self.__get_repo()
return os.path.join(str(repo.working_dir), relative_path)
return str(Path(repo.working_dir) / relative_path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could directly return Path object here. It's re-wrapped everywhere anyways

if preview_env_already_exist:
logging.info("Use existing folder for preview: %s", preview_namespace)
return False
logging.info("Create new folder for preview: %s", preview_namespace)
full_preview_template_folder_path = template_git_repo.get_full_file_path(gitops_config.preview_template_path)
if not os.path.isdir(full_preview_template_folder_path):
if not Path(full_preview_template_folder_path).is_dir():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could extract those checks into a separate dependency to prevent the need to continue to do this ugly monkey patching. Something like path_checker.is_dir(full_preview_template_folder_path)

@patrit patrit merged commit d53eb4c into master Nov 19, 2023
2 checks passed
@patrit patrit deleted the use_pathlib branch November 19, 2023 16:31
Copy link

🎉 This issue has been resolved in version 5.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants