def poetry_config(self): # type: () -> Optional[TOMLDocument] if self._poetry_config is None: self._poetry_config = self.data.get("tool", {}).get("poetry") if self._poetry_config is None: raise PyProjectException( "[tool.poetry] section not found in {}".format(self._file)) return self._poetry_config
def test_show_config_with_local_config_file_empty(tester, mocker): mocker.patch( "poetry.factory.Factory.create_poetry", side_effect=PyProjectException("[tool.poetry] section not found"), ) tester.execute() assert "" == tester.io.fetch_output()
def poetry_config(self) -> Optional[Union["Item", "Container"]]: from tomlkit.exceptions import NonExistentKey try: return self.data["tool"]["poetry"] except NonExistentKey as e: from poetry.core.pyproject.exceptions import PyProjectException raise PyProjectException( "[tool.poetry] section not found in {}".format( self._file)) from e
def poetry_config(self) -> Container: from tomlkit.exceptions import NonExistentKey try: return cast(Container, self.data["tool"]["poetry"]) except NonExistentKey as e: from poetry.core.pyproject.exceptions import PyProjectException raise PyProjectException( f"[tool.poetry] section not found in {self._file}" ) from e
def read(self): try: return super(PyProjectTOMLFile, self).read() except (ValueError, TOMLKitError) as e: raise PyProjectException("Invalid TOML file {}: {}".format( self.path.as_posix(), e))