-
Notifications
You must be signed in to change notification settings - Fork 18
refactor: Use pathlib over os #196
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: Use pathlib over os #196
Conversation
* Use pathlib.Path over os.path in all instances of the codebase.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #196 +/- ##
==========================================
- Coverage 72.38% 71.87% -0.52%
==========================================
Files 3 3
Lines 134 128 -6
==========================================
- Hits 97 92 -5
+ Misses 37 36 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the codebase to use pathlib.Path instead of os.path for all file path operations, improving code readability and modernizing the code to use Python 3's pathlib module.
Key Changes:
- Replaced
os.path.join(),os.path.dirname(),os.path.exists(),os.path.isfile(), andos.makedirs()with pathlib equivalents - Updated type hints to accept
str | Pathwhere appropriate - Removed unused
errnoandosimports where fully replaced
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/test_remote_files.py | Replaced os.path.join with Path / operator for creating test file paths |
| tests/test_local_files.py | Converted directory construction and file existence checks to use Path methods |
| src/skhep_testdata/remote_files.py | Comprehensive refactoring of file operations to pathlib, including directory creation, file checks, and path manipulation; updated type hints to support Path objects |
| setup.py | Replaced os.path.join with Path / operator for file path construction |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ariostas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
|
Thanks @ariostas. I'm going to merge this then with one review, but others are welcome and if there are issues found we can do a follow up PR. |
This is nicer, thank you @matthewfeickert. |
pathlib.Pathoveros.pathin all instances of the codebase.