def exists(self) -> bool:
        """
        :return:
            ``True`` if the submodule exists, ``False`` otherwise.
            Please note that a submodule may exist (in the ``.gitmodules`` file) even
            though its module doesn't exist on disk.
        """
        # Keep attributes for later, and restore them if we have no valid data.
        # This way we do not actually alter the state of the object.
        loc = locals()
        for attr in self._cache_attrs:
            try:
                if hasattr(self, attr):
                    loc[attr] = getattr(self, attr)
                # END if we have the attribute cache
            except (cp.NoSectionError, ValueError):
                # On PY3, this can happen apparently... don't know why this doesn't
                # happen on PY2.
                pass
        # END for each attr
        self._clear_cache()

        try:
            try:
                self.path  # noqa: B018
                return True
            except Exception:
                return False
            # END handle exceptions
        finally:
            for attr in self._cache_attrs:
                if attr in loc:
                    setattr(self, attr, loc[attr])
                # END if we have a cache
            # END reapply each attribute
        # END handle object state consistency

        :return:
            ``True`` if the submodule exists, ``False`` otherwise.
            Please note that a submodule may exist (in the ``.gitmodules`` file) even
            though its module doesn't exist on disk.
        
git/objects/submodule/base.py