Validation library and CLI tool for checking on 'pyproject.toml' files using JSON Schema
Project description
validate-pyproject
Automated checks on pyproject.toml powered by JSON Schema definitions
Description
With the approval of PEP 517 and PEP 518, the Python community shifted towards a strong focus on standardisation for packaging software, which allows more freedom when choosing tools during development and make sure packages created using different technologies can interoperate without the need for custom installation procedures.
This shift became even more clear when PEP 621 was also approved, as a standardised way of specifying project metadata and dependencies.
validate-pyproject was born in this context, with the mission of validating pyproject.toml files, and make sure they are compliant with the standards and PEPs. Behind the scenes, validate-pyproject relies on JSON Schema files, which, in turn, are also a standardised way of checking if a given data structure complies with a certain specification.
Usage
The easiest way of using validate-pyproject is via CLI. To get started, you need to install the package, which can be easily done using pipx:
$ pipx install 'validate-pyproject[all]'
Now you can use validate-pyproject as a command line tool:
# in you terminal
$ validate-pyproject --help
$ validate-pyproject path/to/your/pyproject.toml
You can also use validate-pyproject in your Python scripts or projects:
# in your python code
from validate_pyproject import api, errors
# let's assume that you have access to a `loads` function
# responsible for parsing a string representing the TOML file
# (you can check the `toml` or `tomli` projects for that)
pyproject_as_dict = loads(pyproject_toml_str)
# now we can use validate-pyproject
validator = Validator()
try:
validator(pyproject_as_dict)
except errors.ValidationError as ex:
print(f"Invalid Document: {ex.message}")
To do so, don’t forget to add it to your virtual environment or specify it as a project or library dependency.
More details about validate-pyproject and its Python API can be found in our docs, which includes a description of the used JSON schemas, instructions for using it in a “vendored” way and information about extending the validation with your own plugins.
Note
This project and its sister project ini2toml were initially created in the context of PyScaffold, with the purpose of helping migrating existing projects to PEP 621-style configuration when it is made available on setuptools. For details and usage information on PyScaffold see https://pyscaffold.org/.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file validate-pyproject-0.6.1.tar.gz
.
File metadata
- Download URL: validate-pyproject-0.6.1.tar.gz
- Upload date:
- Size: 101.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2787a8a2c5781ac76e4fb12529cec75f021a265130523fa536f0a47b297334d |
|
MD5 | b8598280c5cd3104210ec692c0c76d7c |
|
BLAKE2b-256 | 740fbd91853adf6ec9df4f0bc364f1912df9f12c358dacf1f095a1f75de8efc8 |
File details
Details for the file validate_pyproject-0.6.1-py3-none-any.whl
.
File metadata
- Download URL: validate_pyproject-0.6.1-py3-none-any.whl
- Upload date:
- Size: 62.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1455538e9b96c2d5f8f7de76103ea38c0c2bffad0453e556f9f23f3efd20e993 |
|
MD5 | 1d172ea42b595b09cba86c7d523693ba |
|
BLAKE2b-256 | c644a5f39c8052197b5a42c8c1532508ac3c8844c2be0eeb00bc5e0a1c3b95f1 |