Determine if a Path or string is a directory on the file system.

def is_dir(path):
    """Determine if a Path or string is a directory on the file system."""
    try:
        return path.expanduser().absolute().is_dir()
    except AttributeError:
        return os.path.isdir(os.path.abspath(os.path.expanduser(str(path))))