mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 13:34:58 +08:00
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:
13
test_cases/stdlib/check_importlib.py
Normal file
13
test_cases/stdlib/check_importlib.py
Normal 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(""))
|
||||
Reference in New Issue
Block a user