Skip to content

Commit

Permalink
refactor: Remove unused warnings = []
Browse files Browse the repository at this point in the history
  • Loading branch information
YDX-2147483647 committed Jun 16, 2023
1 parent f7c829a commit 61eee4c
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/poetry/console/commands/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CheckCommand(Command):
),
]

def validate_classifiers(
def _validate_classifiers(
self, project_classifiers: set[str]
) -> tuple[list[str], list[str]]:
"""Identify unrecognized and deprecated trove classifiers.
Expand Down Expand Up @@ -79,21 +79,18 @@ def validate_classifiers(

return errors, warnings

def validate_readme(
def _validate_readme(
self, readme: str | list[str], poetry_file: Path
) -> tuple[list[str], list[str]]:
) -> list[str]:
"""Check existence of referenced readme files"""

errors = []
warnings: list[str] = []

readmes = [readme] if isinstance(readme, str) else readme

errors = []
for name in readmes:
if not (poetry_file.parent / name).exists():
errors.append(f"Declared README file does not exist: {name}")

return errors, warnings
return errors

def handle(self) -> int:
from poetry.factory import Factory
Expand All @@ -106,15 +103,14 @@ def handle(self) -> int:

# Validate trove classifiers
project_classifiers = set(config.get("classifiers", []))
errors, warnings = self.validate_classifiers(project_classifiers)
errors, warnings = self._validate_classifiers(project_classifiers)
check_result["errors"].extend(errors)
check_result["warnings"].extend(warnings)

# Validate readme (files must exist)
if "readme" in config:
errors, warnings = self.validate_readme(config["readme"], poetry_file)
errors = self._validate_readme(config["readme"], poetry_file)
check_result["errors"].extend(errors)
check_result["warnings"].extend(warnings)

# Verify that lock file is consistent
if self.option("lock") and not self.poetry.locker.is_locked():
Expand Down

0 comments on commit 61eee4c

Please sign in to comment.