Skip to content

Commit

Permalink
Move _validate_pyproject to config
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Mar 30, 2022
1 parent cc55da0 commit 0a5e992
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The code contained in this directory was automatically generated using the
following command:

python -m validate_pyproject.vendoring --output-dir=setuptools/_vendor/_validate_pyproject --enable-plugins setuptools distutils --very-verbose
python -m validate_pyproject.vendoring --output-dir=setuptools/config/_validate_pyproject --enable-plugins setuptools distutils --very-verbose

Please avoid changing it manually.

Expand Down Expand Up @@ -31,7 +31,7 @@ by the same projects:
- `__init__.py`
- `fastjsonschema_validations.py`

The relevant copyright notes and licenses are included below.
The relevant copyright notes and licenses are included bellow.


***
Expand Down
14 changes: 4 additions & 10 deletions setuptools/config/pyprojecttoml.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,12 @@ def load_file(filepath: _Path) -> dict:
return tomli.load(file)


def validate(config: dict, filepath: _Path):
from setuptools.extern._validate_pyproject import validate as _validate
def validate(config: dict, filepath: _Path) -> bool:
from . import _validate_pyproject as validator

try:
return _validate(config)
except Exception as ex:
if ex.__class__.__name__ != "ValidationError":
# Workaround for the fact that `extern` can duplicate imports
ex_cls = ex.__class__.__name__
error = ValueError(f"invalid pyproject.toml config: {ex_cls} - {ex}")
raise error from None

return validator._validate(config)
except validator.ValidationError as ex:
_logger.error(f"configuration error: {ex.summary}") # type: ignore
_logger.debug(ex.details) # type: ignore
error = ValueError(f"invalid pyproject.toml config: {ex.name}") # type: ignore
Expand Down
3 changes: 1 addition & 2 deletions setuptools/extern/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def install(self):

names = (
'packaging', 'pyparsing', 'ordered_set', 'more_itertools', 'importlib_metadata',
'zipp', 'importlib_resources', 'jaraco', 'typing_extensions', 'nspektr',
'tomli', '_validate_pyproject',
'zipp', 'importlib_resources', 'jaraco', 'typing_extensions', 'nspektr', 'tomli',
)
VendorImporter(__name__, names, 'setuptools._vendor').install()

0 comments on commit 0a5e992

Please sign in to comment.