check.py (poetry-1.1.15) | : | check.py (poetry-1.2.0) | ||
---|---|---|---|---|
from poetry.core.pyproject.toml import PyProjectTOML | from __future__ import annotations | |||
from poetry.factory import Factory | ||||
from poetry.utils._compat import Path | ||||
from .command import Command | from pathlib import Path | |||
class CheckCommand(Command): | from poetry.console.commands.command import Command | |||
class CheckCommand(Command): | ||||
name = "check" | name = "check" | |||
description = "Checks the validity of the <comment>pyproject.toml</comment> file." | description = "Checks the validity of the <comment>pyproject.toml</comment> file." | |||
def handle(self): | def handle(self) -> int: | |||
from poetry.core.pyproject.toml import PyProjectTOML | ||||
from poetry.factory import Factory | ||||
# Load poetry config and display errors, if any | # Load poetry config and display errors, if any | |||
poetry_file = Factory.locate(Path.cwd()) | poetry_file = Factory.locate(Path.cwd()) | |||
config = PyProjectTOML(poetry_file).poetry_config | config = PyProjectTOML(poetry_file).poetry_config | |||
check_result = Factory.validate(config, strict=True) | check_result = Factory.validate(config, strict=True) | |||
if not check_result["errors"] and not check_result["warnings"]: | if not check_result["errors"] and not check_result["warnings"]: | |||
self.info("All set!") | self.info("All set!") | |||
return 0 | return 0 | |||
for error in check_result["errors"]: | for error in check_result["errors"]: | |||
self.line("<error>Error: {}</error>".format(error)) | self.line_error(f"<error>Error: {error}</error>") | |||
for error in check_result["warnings"]: | for error in check_result["warnings"]: | |||
self.line("<warning>Warning: {}</warning>".format(error)) | self.line_error(f"<warning>Warning: {error}</warning>") | |||
return 1 | return 1 | |||
End of changes. 7 change blocks. | ||||
8 lines changed or deleted | 11 lines changed or added |