Type annotations: pathlib.Path vs importlib.resources.abc.Traversable
Advertisements When loading file resources that are bundled inside my distribution package, I use importlib.resources.files. When loading files from disk, I use pathlib.Path. Sometimes I want to write a function that will take either: from importlib.resources.abc import Traversable from pathlib import Path def process_file(file_to_process: Traversable | Path) -> None: … It feels cumbersome to annotate… Read More Type annotations: pathlib.Path vs importlib.resources.abc.Traversable