Skip to content

Conversation

Gobot1234
Copy link
Collaborator

@Gobot1234 Gobot1234 commented Oct 15, 2025

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

@Copilot Copilot AI review requested due to automatic review settings October 15, 2025 09:01
Copy link
Contributor

@Copilot Copilot AI left a 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.

@github-actions github-actions bot added the new feature Request or proposal for a new feature label Oct 15, 2025
@Copilot Copilot AI review requested due to automatic review settings October 15, 2025 09:16
@Gobot1234 Gobot1234 force-pushed the jhilton-/improve-pathlike-support branch from 12f41a8 to b9cf0c7 Compare October 15, 2025 09:16
Copy link
Contributor

@Copilot Copilot AI left a 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.

@Gobot1234 Gobot1234 enabled auto-merge (squash) October 15, 2025 09:18
@Copilot Copilot AI review requested due to automatic review settings October 17, 2025 10:07
Copy link
Contributor

@Copilot Copilot AI left a 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."""
Copy link

Copilot AI Oct 17, 2025

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.

Suggested change
"""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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature Request or proposal for a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants