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

refactor: refactor codebase to use pathlib instead of os.path #106

Merged

Conversation

filipchristiansen
Copy link
Collaborator

@filipchristiansen filipchristiansen commented Jan 6, 2025

This PR replaces all occurrences of os.path with the pathlib library to enhance code clarity, maintainability, and cross-platform consistency. Key changes include:

  • Converting string-based path manipulations to Path objects.
  • Using path.relative_to(...) to obtain relative paths instead of naive string replacements.
  • Replacing os.path.join(), os.path.exists(), os.path.abspath(...), os.path.basename(...), os.path.dirname(...), os.path.getctime(...), os.listdir(...), and similar functions with the equivalent Path methods.

By leveraging pathlib’s object-oriented approach, we ensure fewer edge cases in path handling, especially on different operating systems. The tests have been updated to reflect these changes and should pass as expected.

Copy link
Owner

@cyclotruc cyclotruc left a comment

Choose a reason for hiding this comment

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

Very good thank you!
I tested in codespaces and everything seemed to work perfectly

src/routers/download.py Show resolved Hide resolved
@cyclotruc cyclotruc merged commit 123f0ef into cyclotruc:main Jan 7, 2025
8 checks passed
@filipchristiansen filipchristiansen deleted the feature/refactor-pathlib branch January 7, 2025 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants