Skip to content

Commit

Permalink
Update validate_pyproject to 0.22
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p committed Oct 27, 2024
1 parent a9a79e7 commit 6998ef2
Show file tree
Hide file tree
Showing 5 changed files with 267 additions and 135 deletions.
2 changes: 1 addition & 1 deletion setuptools/config/_validate_pyproject/NOTICE
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.pre_compile --output-dir=setuptools/config/_validate_pyproject --enable-plugins setuptools distutils --very-verbose -t distutils=setuptools/config/distutils.schema.json -t setuptools=setuptools/config/setuptools.schema.json
python -m validate_pyproject.pre_compile --output-dir=setuptools/config/_validate_pyproject --enable-plugins setuptools distutils --very-verbose -t setuptools=setuptools/config/setuptools.schema.json -t distutils=setuptools/config/distutils.schema.json

Please avoid changing it manually.

Expand Down
32 changes: 31 additions & 1 deletion setuptools/config/_validate_pyproject/extra_validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ class RedefiningStaticFieldAsDynamic(ValidationError):
)


class IncludedDependencyGroupMustExist(ValidationError):
_DESC = """An included dependency group must exist and must not be cyclic.
"""
__doc__ = _DESC
_URL = "https://peps.python.org/pep-0735/"


def validate_project_dynamic(pyproject: T) -> T:
project_table = pyproject.get("project", {})
dynamic = project_table.get("dynamic", [])
Expand All @@ -49,4 +56,27 @@ def validate_project_dynamic(pyproject: T) -> T:
return pyproject


EXTRA_VALIDATIONS = (validate_project_dynamic,)
def validate_include_depenency(pyproject: T) -> T:
dependency_groups = pyproject.get("dependency-groups", {})
for key, value in dependency_groups.items():
for each in value:
if (
isinstance(each, dict)
and (include_group := each.get("include-group"))
and include_group not in dependency_groups
):
raise IncludedDependencyGroupMustExist(
message=f"The included dependency group {include_group} doesn't exist",
value=each,
name=f"data.dependency_groups.{key}",
definition={
"description": cleandoc(IncludedDependencyGroupMustExist._DESC),
"see": IncludedDependencyGroupMustExist._URL,
},
rule="PEP 735",
)
# TODO: check for `include-group` cycles (can be conditional to graphlib)
return pyproject


EXTRA_VALIDATIONS = (validate_project_dynamic, validate_include_depenency)
351 changes: 222 additions & 129 deletions setuptools/config/_validate_pyproject/fastjsonschema_validations.py

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions setuptools/config/_validate_pyproject/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,15 @@ class _TroveClassifier:
"""

downloaded: typing.Union[None, "Literal[False]", typing.Set[str]]
"""
None => not cached yet
False => unavailable
set => cached values
"""

def __init__(self) -> None:
self.downloaded = None
self._skip_download = False
# None => not cached yet
# False => cache not available
self.__name__ = "trove_classifier" # Emulate a public function

def _disable_download(self) -> None:
Expand Down Expand Up @@ -351,7 +354,7 @@ def python_entrypoint_reference(value: str) -> bool:
obj = rest

module_parts = module.split(".")
identifiers = _chain(module_parts, obj.split(".")) if rest else module_parts
identifiers = _chain(module_parts, obj.split(".")) if rest else iter(module_parts)
return all(python_identifier(i.strip()) for i in identifiers)


Expand All @@ -373,3 +376,9 @@ def uint(value: builtins.int) -> bool:
def int(value: builtins.int) -> bool:
r"""Signed 64-bit integer (:math:`-2^{63} \leq x < 2^{63}`)"""
return -(2**63) <= value < 2**63


def SPDX(value: str) -> bool:
"""Should validate eventually"""
# TODO: validate conditional to the presence of (the right version) of packaging
return True
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ commands =
[testenv:generate-validation-code]
skip_install = True
deps =
validate-pyproject[all]==0.19
validate-pyproject[all]==0.22
commands =
python -m tools.generate_validation_code

Expand Down

0 comments on commit 6998ef2

Please sign in to comment.