Simplify Traversable signature (#10934)

Simplify Traversable.open() signature. This is necessary so that implentors can
reasonanbly implement this method. For example `zipfile.Path.open()` (which
is considered a `Traversable`) only supports this subset.

Make `Traversable.__truediv__` and `joinpath` arguments pos-only. The
arguments are named differently in both `pathlib.Path` and `zipfile.Path`.
This commit is contained in:
Sebastian Rittau
2023-10-27 00:50:11 +02:00
committed by GitHub
parent a08d4c8d2e
commit 1c184fea33
6 changed files with 40 additions and 70 deletions

View File

@@ -0,0 +1,13 @@
import importlib.abc
import pathlib
import sys
import zipfile
# Assert that some Path classes are Traversable.
if sys.version_info >= (3, 9):
def traverse(t: importlib.abc.Traversable) -> None:
pass
traverse(pathlib.Path())
traverse(zipfile.Path(""))