-
Notifications
You must be signed in to change notification settings - Fork 56
feat: PathLike support throughout #4558
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: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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 adds PathLike support throughout the library to improve usability with pathlib.Path objects. The change introduces a PathType type alias and updates function parameters to accept path-like objects in addition to strings.
- Introduces PathType type alias for path parameters
- Updates function signatures to use PathType instead of str for path parameters
- Maintains backward compatibility while enabling pathlib.Path usage
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
12f41a8
to
b9cf0c7
Compare
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
Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
from typing import TypeAlias | ||
|
||
PathType: TypeAlias = "os.PathLike[str | bytes] | str | bytes" | ||
"""Type alias for file system paths.""" |
Copilot
AI
Oct 17, 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.
[nitpick] The type alias definition uses a forward reference string but doesn't explain the rationale. Consider adding a docstring comment explaining why os.PathLike[str | bytes] | str | bytes
is used instead of just os.PathLike[str]
, particularly the inclusion of bytes support.
"""Type alias for file system paths.""" | |
""" | |
Type alias for file system paths. | |
This alias includes both string and bytes types, as well as their corresponding | |
os.PathLike variants, to support APIs that accept file system paths as either | |
str, bytes, os.PathLike[str], or os.PathLike[bytes]. This matches the conventions | |
used in the Python standard library, where many functions accept both str and bytes | |
paths for compatibility with different file system encodings and legacy code. | |
The use of a forward reference string is to avoid issues with type checking and | |
circular imports in some environments. | |
""" |
Copilot uses AI. Check for mistakes.
Context
Currently everything is typed as a str for Path but can still work in some places. This PR adds support for Paths I think everywhere in the public API
Change Summary
Gone through the library to find anything with path in it and update them to support os.fspath calls
Rationale
It makes things a lot nicer to use if you can use pathlib.Path
Impact
I don't think there's a big impact to anyone