-
Notifications
You must be signed in to change notification settings - Fork 43
Pathlib and perf #823
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
base: master
Are you sure you want to change the base?
Pathlib and perf #823
Conversation
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 pull request modernizes the codebase by replacing os.path and os module calls with pathlib.Path operations, providing better performance and more readable code.
Key changes:
- Replaces all
os.pathoperations with equivalentpathlib.Pathmethods - Removes unused
osmodule imports - Improves code readability and maintainability through modern Python path handling
| # Use pathlib for cleaner path operations | ||
| return Path(full_path).name |
Copilot
AI
Sep 18, 2025
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.
The function name get_directory_name_from_full_path suggests it should return a directory name, but Path.name returns the final component of the path (which could be a file). The original code used os.path.basename(os.path.split(normalized_path)[1]) which had different behavior. This change may break functionality if callers expect directory-specific behavior.
| # Use pathlib for cleaner path operations | |
| return Path(full_path).name | |
| # Return the name of the parent directory, even if the path ends with a file | |
| return Path(full_path).parent.name |
| capture_output=True, | ||
| text=True, | ||
| cwd=os_path.dirname(__file__), | ||
| cwd=Path(__file__).parent, |
Copilot
AI
Sep 18, 2025
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.
The cwd parameter expects a string path, but Path(__file__).parent returns a Path object. This should be converted to string: cwd=str(Path(__file__).parent)
| cwd=Path(__file__).parent, | |
| cwd=str(Path(__file__).parent), |
| git_hash_file = os_path.join(os_path.dirname(__file__), "git_hash.txt") | ||
| git_hash_file = Path(__file__).parent / "git_hash.txt" | ||
| try: | ||
| with open(git_hash_file, encoding="utf-8") as file: |
Copilot
AI
Sep 18, 2025
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.
The open() function expects a string path, but git_hash_file is a Path object. Convert to string: with open(str(git_hash_file), encoding=\"utf-8\") as file:
| with open(git_hash_file, encoding="utf-8") as file: | |
| with open(str(git_hash_file), encoding="utf-8") as file: |
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
Test Results 1 files - 1 1 suites - 1 58s ⏱️ -49s For more details on these failures, see this check. Results for commit db41783. ± Comparison against base commit c0d7d34. ♻️ This comment has been updated with latest results. |
3541d9c to
d783fcd
Compare
d783fcd to
db41783
Compare
No description provided.