Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/5897.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Change `PathBuf::extract` input type hint from `str | os.PathLike` to `str | os.PathLike[str]`
2 changes: 1 addition & 1 deletion pytests/stubs/path.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ from os import PathLike
from pathlib import Path

def make_path() -> Path: ...
def take_pathbuf(path: str | PathLike) -> Path: ...
def take_pathbuf(path: str | PathLike[str]) -> Path: ...
7 changes: 5 additions & 2 deletions src/conversions/std/path.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::conversion::IntoPyObject;
use crate::ffi_ptr_ext::FfiPtrExt;
#[cfg(feature = "experimental-inspect")]
use crate::inspect::{type_hint_identifier, type_hint_union, PyStaticExpr};
use crate::inspect::{type_hint_identifier, type_hint_subscript, type_hint_union, PyStaticExpr};
use crate::sync::PyOnceLock;
use crate::types::any::PyAnyMethods;
use crate::{ffi, Borrowed, Bound, FromPyObject, Py, PyAny, PyErr, Python};
Expand All @@ -15,7 +15,10 @@ impl FromPyObject<'_, '_> for PathBuf {
#[cfg(feature = "experimental-inspect")]
const INPUT_TYPE: PyStaticExpr = type_hint_union!(
OsString::INPUT_TYPE,
type_hint_identifier!("os", "PathLike")
type_hint_subscript!(
type_hint_identifier!("os", "PathLike"),
OsString::INPUT_TYPE
)
);

fn extract(ob: Borrowed<'_, '_, PyAny>) -> Result<Self, Self::Error> {
Expand Down
Loading