-
Notifications
You must be signed in to change notification settings - Fork 1.9k
docs: Rewrite Handling Paths chapter (pathlib vs utils) #6116
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?
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 PR rewrites the "Handling Paths" chapter in the contributing documentation to reflect the transition from legacy path utilities (syspath()
, normpath()
, bytestring_path()
, displayable_path()
) to modern pathlib.Path
. The documentation now includes historical context explaining why the old utilities existed, guidance on when to use each approach, and concrete examples showing old vs. new patterns.
- Adds historical context for legacy path utilities and their original purposes
- Introduces
pathlib.Path
as the preferred approach for new code - Provides side-by-side examples comparing old and new path handling patterns
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
New style:: | ||
|
||
item.filepath | ||
Path("~/Music/../Artist").expanduser().resolve() |
Copilot
AI
Oct 21, 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.
Using resolve()
in the example may be misleading as it canonicalizes the path by resolving symlinks and making it absolute, which differs from normpath()
's behavior. normpath()
only normalized slashes and removed .
and ..
without resolving symlinks or making paths absolute. Consider using Path(...).expanduser()
alone or clarifying that resolve()
does more than the old normpath()
.
Path("~/Music/../Artist").expanduser().resolve() | |
Path("~/Music/../Artist").expanduser() |
Copilot uses AI. Check for mistakes.
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.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6116 +/- ##
=======================================
Coverage 66.98% 66.98%
=======================================
Files 118 118
Lines 18189 18191 +2
Branches 3079 3079
=======================================
+ Hits 12184 12186 +2
- Misses 5345 5346 +1
+ Partials 660 659 -1 🚀 New features to boost your workflow:
|
How do we feel about moving this into the developer documentation? I don't think it should be included in the contribution guide. |
|
||
Old style:: | ||
|
||
displayable_path(item.path) |
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.
Can we use the full .. code-block:: python
blocks? Otherwise my editor wont pick up highlighting 😢
Good idea! I keep forgetting n starting to look for it there anyway!! 😂 |
Description
Updates the docs chapter "Handling Paths" describing how to modernise old code and intentionally includes historical details. Examples should further guide contributors while refactoring.
To Do
docs/
to describe it.)docs/changelog.rst
to the bottom of one of the lists near the top of the document.)