@lru_cache(maxsize=<NUM_LIT>)<EOL>def ensure_path(path):<EOL>
if isinstance(path, vistir.compat.Path):<EOL><INDENT>return path<EOL><DEDENT>path = vistir.compat.Path(os.path.expandvars(path))<EOL>return path.absolute()<EOL>
Given a path (either a string or a Path object), expand variables and return a Path object.

:param path: A string or a :class:`~pathlib.Path` object.
:type path: str or :class:`~pathlib.Path`
:return: A fully expanded Path object.
:rtype: :class:`~pathlib.Path`