From c17f5cb26b3d1142b0e099f534f5a247ace7e463 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Sun, 6 Aug 2023 21:43:13 -0400 Subject: [PATCH] chore: single file & 3.6 import Signed-off-by: Henry Schreiner --- setup.cfg | 4 +-- src/validate_pyproject/repo_review.py | 36 +++++++++++++++++++ .../repo_review/__init__.py | 0 src/validate_pyproject/repo_review/checks.py | 28 --------------- .../repo_review/families.py | 17 --------- 5 files changed, 38 insertions(+), 47 deletions(-) create mode 100644 src/validate_pyproject/repo_review.py delete mode 100644 src/validate_pyproject/repo_review/__init__.py delete mode 100644 src/validate_pyproject/repo_review/checks.py delete mode 100644 src/validate_pyproject/repo_review/families.py diff --git a/setup.cfg b/setup.cfg index f487672..7c50c30 100644 --- a/setup.cfg +++ b/setup.cfg @@ -87,9 +87,9 @@ validate_pyproject.tool_schema = setuptools = validate_pyproject.api:load_builtin_plugin distutils = validate_pyproject.api:load_builtin_plugin repo_review.checks = - validate_pyproject = validate_pyproject.repo_review.checks:repo_review_checks + validate_pyproject = validate_pyproject.repo_review:repo_review_checks repo_review.families = - validate_pyproject = validate_pyproject.repo_review.families:repo_review_families + validate_pyproject = validate_pyproject.repo_review:repo_review_families [tool:pytest] # Specify command line options as you would do when invoking pytest directly. diff --git a/src/validate_pyproject/repo_review.py b/src/validate_pyproject/repo_review.py new file mode 100644 index 0000000..58ce2e3 --- /dev/null +++ b/src/validate_pyproject/repo_review.py @@ -0,0 +1,36 @@ +from typing import Any, Dict + +import fastjsonschema + +from .. import api, plugins + +__all__ = ["VPP001", "repo_review_checks", "repo_review_families"] + + +class VPP001: + """Validate pyproject.toml""" + + family = "validate-pyproject" + + @staticmethod + def check(pyproject: Dict[str, Any]) -> str: + validator = api.Validator() + try: + validator(pyproject) + return "" + except fastjsonschema.JsonSchemaValueException as e: + return f"Invalid pyproject.toml! Error: {e}" + + +def repo_review_checks() -> Dict[str, VPP001]: + return {"VPP001": VPP001()} + + +def repo_review_families(pyproject: Dict[str, Any]) -> Dict[str, Dict[str, str]]: + has_distutils = "distutils" in pyproject.get("tool", {}) + plugin_names = (ep.name for ep in plugins.iterate_entry_points()) + plugin_list = ( + f"`[tool.{n}]`" for n in plugin_names if n != "distutils" or has_distutils + ) + descr = f"Checks `[build-system]`, `[project]`, {', '.join(plugin_list)}" + return {"validate-pyproject": {"name": "Validate-PyProject", "description": descr}} diff --git a/src/validate_pyproject/repo_review/__init__.py b/src/validate_pyproject/repo_review/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/validate_pyproject/repo_review/checks.py b/src/validate_pyproject/repo_review/checks.py deleted file mode 100644 index 1a09870..0000000 --- a/src/validate_pyproject/repo_review/checks.py +++ /dev/null @@ -1,28 +0,0 @@ -from __future__ import annotations - -from typing import Any - -import fastjsonschema - -from .. import api - -__all__ = ["VPP001", "repo_review_checks"] - - -class VPP001: - """Validate pyproject.toml""" - - family = "validate-pyproject" - - @staticmethod - def check(pyproject: dict[str, Any]) -> str: - validator = api.Validator() - try: - validator(pyproject) - return "" - except fastjsonschema.JsonSchemaValueException as e: - return f"Invalid pyproject.toml! Error: {e}" - - -def repo_review_checks() -> dict[str, VPP001]: - return {"VPP001": VPP001()} diff --git a/src/validate_pyproject/repo_review/families.py b/src/validate_pyproject/repo_review/families.py deleted file mode 100644 index e50f768..0000000 --- a/src/validate_pyproject/repo_review/families.py +++ /dev/null @@ -1,17 +0,0 @@ -from __future__ import annotations - -from typing import Any - -from .. import plugins - -__all__ = ["repo_review_families"] - - -def repo_review_families(pyproject: dict[str, Any]) -> dict[str, dict[str, str]]: - has_distutils = "distutils" in pyproject.get("tool", {}) - plugin_names = (ep.name for ep in plugins.iterate_entry_points()) - plugin_list = ( - f"`[tool.{n}]`" for n in plugin_names if n != "distutils" or has_distutils - ) - descr = f"Checks `[build-system]`, `[project]`, {', '.join(plugin_list)}" - return {"validate-pyproject": {"name": "Validate-PyProject", "description": descr}}