codekingpro/portable-devtools
115k
1from __future__ import annotations2 3 4TYPE_CHECKING = False5 6if TYPE_CHECKING:7 import subprocess8 import types9 10 11class BuildException(Exception):12 """13 Exception raised by :class:`build.ProjectBuilder`.14 """15 16 17class BuildBackendException(Exception):18 """19 Exception raised when a backend operation fails.20 """21 22 def __init__(23 self,24 exception: Exception,25 description: str | None = None,26 exc_info: tuple[type[BaseException], BaseException, types.TracebackType] | tuple[None, None, None] = (27 None,28 None,29 None,30 ),31 ) -> None:32 super().__init__()33 self.exception = exception34 self.exc_info = exc_info35 self._description = description36 37 def __str__(self) -> str:38 if self._description:39 return self._description40 return f'Backend operation failed: {self.exception!r}'41 42 43class BuildSystemTableValidationError(BuildException):44 """45 Exception raised when the ``[build-system]`` table in pyproject.toml is invalid.46 """47 48 def __str__(self) -> str:49 return f'Failed to validate `build-system` in pyproject.toml: {self.args[0]}'50 51 52class FailedProcessError(Exception):53 """54 Exception raised when a setup or preparation operation fails.55 """56 57 def __init__(self, exception: subprocess.CalledProcessError, description: str) -> None:58 super().__init__()59 self.exception = exception60 self._description = description61 62 def __str__(self) -> str:63 return self._description64 65 66class TypoWarning(Warning):67 """68 Warning raised when a possible typo is found.69 """70 