From c0f3789460540aec76a54bea30f2bbcb0028dd00 Mon Sep 17 00:00:00 2001 From: Bernat Gabor Date: Thu, 16 Jul 2026 09:29:36 -0700 Subject: [PATCH] Make SimplePath path parameters positional-only pathlib.Path does not satisfy SimplePath under ty or pyrefly. The protocol names the joinpath and __truediv__ parameter `other`, while typeshed names Path's `key` and `*other`. Neither side is positional-only, so the typing spec requires the names to match, and they do not. Marking the parameters positional-only reflects how both members are called and lets Path satisfy the protocol. mypy passes before and after. Closes #542 --- importlib_metadata/_meta.py | 4 ++-- newsfragments/542.bugfix.rst | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 newsfragments/542.bugfix.rst diff --git a/importlib_metadata/_meta.py b/importlib_metadata/_meta.py index 0c20eff3..219b2a86 100644 --- a/importlib_metadata/_meta.py +++ b/importlib_metadata/_meta.py @@ -54,11 +54,11 @@ class SimplePath(Protocol): """ def joinpath( - self, other: str | os.PathLike[str] + self, other: str | os.PathLike[str], / ) -> SimplePath: ... # pragma: no cover def __truediv__( - self, other: str | os.PathLike[str] + self, other: str | os.PathLike[str], / ) -> SimplePath: ... # pragma: no cover @property diff --git a/newsfragments/542.bugfix.rst b/newsfragments/542.bugfix.rst new file mode 100644 index 00000000..316e28ba --- /dev/null +++ b/newsfragments/542.bugfix.rst @@ -0,0 +1 @@ +Marked the ``other`` parameter of ``SimplePath.joinpath`` and ``SimplePath.__truediv__`` positional-only, so ``pathlib.Path`` satisfies the protocol under type checkers that compare parameter names.