class StringLike(abc.ABC):@abstractmethoddef __str__(self):"""Return the string representation of something."""StringLike.register(pathlib.PurePath) # Any 3rd-party library can do the same.You could also call the class StringablePath or something and get the exact same concept across where you are using the registration abilities of ABCs to semantically delineate when a class's __str__() returns a usable file path.The drawback is that this isn't easily backported like `path.__ospath__() if hasattr(path, '__ospath__') else path` for libraries that don't necessarily have access to pathlib but want to be compatible with accepting path objects.