drytoml
Keep your toml configuration centralized and personalizable.
Through drytoml, TOML files can have references to any content from another TOML file.
References work with relative/absolute paths and urls, and can point to whole files, a
specific table, or in general anything reachable by a sequence of getitem calls, like
["tool", "poetry", "source", 0, "url"]. drytoml takes care of transcluding the
content for you.
Inspired by flakehell and
nitpick, the main motivation behind drytoml is to
have several projects sharing a common, centralized configuration defining codestyles,
but still allowing granular control when required.
This is a deliberate departure from nitpick, which works as a linter instead, ensuring your local files have the right content.
Usage
drytoml has two main usages:
-
Use a file as a reference and "build" the resulting one:
# contents of pyproject.dry.toml ... [tool.black] __extends = "../../common/black.toml" target-version = ['py37'] include = '\.pyi?$' ...
# contents of ../../common/black.toml [tool.black] line-length = 100
$ dry export --file=pyproject.dry.toml > pyproject.toml
# contents of pyproject.toml [tool.black] line-length = 100 target-version = ['py37'] include = '\.pyi?$'
-
Use included wrappers, allowing you to use references in your current configuration without changing any file:
Consider the original
pyproject.dry.tomlfrom the example above, an alternative usage fordrytomlis shown next. Instead of this:$ black . All done! ✨ 🍰 ✨ 14 files left unchanged.
You would run this:
$ dry black reformatted /path/to/cwd/file_with_potentially_long_lines.py reformatted /path/to/cwd/another_file_with_potentially_long_lines.py All done! ✨ 🍰 ✨ 2 files reformatted, 12 files left unchanged.
What just happened?
drytomlcomes with a set of wrappers which- Create a transcluded temporary file, equivalent to the resulting
pyproject.tomlin the example above - Configure the wrapped tool (
blackin this case) to use the temporary file - Run
black, and get rid of the file on exit.
- Create a transcluded temporary file, equivalent to the resulting
For the moment, the following wrappers are available (more to come, contributions are welcome):
In the works:
- docformatter
- pytest
Notes
Although the flakehell project was archived, we're keeping a fork alive from here, availabe as flakeheaven in pypi.
Setup
Prerequisites
- A compatible python >3.6.9
- [recommended] virtualenv
- A recent
pip
Install
Install as usual, with pip, poetry, etc:
pip install drytomlpoetry add drytoml(probably you'll wantpoetry add --dev drytomlinstead)
Usage
For any command , run --help to find out flags and usage.
Some of the most common are listed below:
- Use any of the provided wrappers as a subcommand, eg
dry blackinstead ofblack. - Use
dry -q exportand redirect to a file, to generate a new file with transcluded contents - Use
dry cacheto manage the cache for remote references.
FAQ
Q: I want to use a different key to trigger transclusions
A: In cli mode (using the dry command), you can pass the --key flagcli, to change
it. In api mode (from python code), initialize drytoml.parser.Parser using a
custom value for the extend_key kwarg.
Q: I changed a referenced toml upstream (eg in github) but still get the same result.
A: Run dry cache clear --help to see available options.
Contribute
Start by creating an issue, forking the project and creating a Pull Request.
Setting up the development environment
If you have docker, the easiest way is to use the provided devcontainer inside vscode,
which already contains everything pre-installed. You must open the cloned directory
using the remote-containers extension.
Just run poetry shell or prepend any command with poetry run to ensure commands
are run inside the virtual environment.
Alternatively, you can use poetry: poetry install -E dev
The next steps assume you have already activated the venv.
Committing
-
Commits in every branch must adhere to Conventional Commits. Releases are done automatically and require conventional commits messages compliance.
-
To validate commits, you can install the pre-commit hook
pre-commit install --hook-type commit-msg -
With venv activated, you can commit using
cz commitinstead ofgit committo ensure compliance.
Running checks
You can look at the different actions defined in .github/workflows. There are three
ways to check your code:
-
Remotely, by pushing to an open PR. You'll se the results in the PR page.
-
Manually, executing the check from inside a venv
For example, to generate the documentation, check
.github/workflows/docs. To run theBuild with Sphinxstep:sphinx-build docs/src docs/buildOr to run pytest, from
.github/workflows/tests.yml:sphinx-build docs/src docs/build... etc
-
Locally, with act (Already installed in the devcontainer)
For example, to emulate a PR run for the tests workflow:
act -W .github/workflows/tests.yml pull_request
TODO
Check out current development here
Metadata
Release files for drytoml 0.2.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| drytoml-0.2.8.tar.gz | 19.2 kB | Without provenance | Details for drytoml-0.2.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| drytoml-0.2.8-py3-none-any.whl | Python 3 | none | any | Details for drytoml-0.2.8-py3-none-any.whl |
Total release size: 37.8 kB
Release files / drytoml-0.2.8.tar.gz
| Download URL | drytoml-0.2.8.tar.gz |
|---|---|
| Size | 19.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0ea50bb980c5fc426dd3fff735e603fd94d4500e496c24d102273b7d01041ed8
|
|
BLAKE2b-256 checksum How to use checksums |
bbf9480817a01ffd1b47679b9542291c475d6cabc6f805ec23f8940a82b2ff8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.9.1 Linux/5.4.0-1039-azure
|
Release files / drytoml-0.2.8-py3-none-any.whl
| Download URL | drytoml-0.2.8-py3-none-any.whl |
|---|---|
| Size | 18.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c7d1231cb1cad3ab0650498a9b214b85e5d7cf314ab982bd6be1018f770d6cbe
|
|
BLAKE2b-256 checksum How to use checksums |
e3009659c2823f0f6634a21536d0050456dc009e2dadea0b3e460882cefd5b02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.9.1 Linux/5.4.0-1039-azure
|
Security for drytoml 0.2.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.