code: def get_version(package: Union[Path, str]) -> str:
      
      path = Path(package)
      if not path.suffix and len(path.parts) == 1:  # Is probably not a path
          v = get_version_from_metadata(package)
          if v:
              return str(v)
  
      if path.suffix != ".py":
          msg = f"“package” is neither the name of an installed module nor the path to a .py file."
          if path.suffix:
              msg += f" Unknown file suffix {path.suffix}"
          raise ValueError(msg)
      if path.name == "__init__.py":
          name = path.parent.name
          parent = path.parent.parent
      else:
          name = path.with_suffix("").name
          parent = path.parent
  
      return str(
          get_version_from_dirname(name, parent)
          or get_version_from_git(parent)
          or get_version_from_metadata(name, parent)
          or "0.0.0"
      )
docs: Get the version of a package or module
      Pass a module path or package name.
      The former is recommended, since it also works for not yet installed packages.
      Supports getting the version from
      #. The directory name (as created by ``setup.py sdist``)
      #. The output of ``git describe``
      #. The package metadata of an installed package
         (This is the only possibility when passing a name)
      Args:
         package: package name or module path (``…/module.py`` or ``…/module/__init__.py``)