As of Python 3.10, the following types are picklable:
from pathlib import Path
from typing import NewType
File = NewType("File", Path)
Directory = NewType("Directory", Path)
Prior to that, this fails. Would it be possible to backport the NewType class to Python 3.7+?