diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e08559a..8eb85a8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,8 @@ Changelog Development Version ==================== +* Added support for specifying package-data for stub packages, #248. + Version 0.24.1 ============== diff --git a/src/validate_pyproject/formats.py b/src/validate_pyproject/formats.py index 1cf4a46..ae01699 100644 --- a/src/validate_pyproject/formats.py +++ b/src/validate_pyproject/formats.py @@ -313,6 +313,15 @@ def python_module_name_relaxed(value: str) -> bool: return python_module_name(value.replace("-", "_")) +def package_data_module_name_or_wildcard(value: str) -> bool: + """Python module name, stubs package name or wildcard used for package-data.""" + if value == "*": + return True + if python_module_name(value): + return True + return pep561_stub_name(value) + + def python_entrypoint_group(value: str) -> bool: """See ``Data model > group`` in the :ref:`PyPA's entry-points specification `. diff --git a/src/validate_pyproject/plugins/setuptools.schema.json b/src/validate_pyproject/plugins/setuptools.schema.json index ec887b3..330085d 100644 --- a/src/validate_pyproject/plugins/setuptools.schema.json +++ b/src/validate_pyproject/plugins/setuptools.schema.json @@ -115,9 +115,7 @@ ], "type": "object", "additionalProperties": false, - "propertyNames": { - "anyOf": [{"type": "string", "format": "python-module-name"}, {"const": "*"}] - }, + "propertyNames": {"type": "string", "format": "package-data-module-name-or-wildcard"}, "patternProperties": { "^.*$": {"type": "array", "items": {"type": "string"}} } @@ -139,9 +137,7 @@ ], "type": "object", "additionalProperties": false, - "propertyNames": { - "anyOf": [{"type": "string", "format": "python-module-name"}, {"const": "*"}] - }, + "propertyNames": {"type": "string", "format": "package-data-module-name-or-wildcard"}, "patternProperties": { "^.*$": {"type": "array", "items": {"type": "string"}} } diff --git a/tests/examples/setuptools/08-pyproject.toml b/tests/examples/setuptools/08-pyproject.toml index 0e7ccd9..e01ee07 100644 --- a/tests/examples/setuptools/08-pyproject.toml +++ b/tests/examples/setuptools/08-pyproject.toml @@ -16,3 +16,7 @@ packages = ["mypkg-stubs"] [tool.setuptools.package-data] "*" = ["*.pyi"] +"mypkg-stubs" = ["METADATA.toml"] + +[tool.setuptools.exclude-package-data] +"mypkg-stubs" = ["*.rst"]