The various config files

Customisation and prevention of customisation

Nens-meta tries to be only as invasive as necessary and to get out of your way where possible. The config files have two basic customisation tweaks.

  • If the literal text NENS_META_LEAVE_ALONE, in all caps, is found anywhere in a file, it is left alone. A similarly-named file with a .suggestion extension is written instead.

  • Most files have an ### Extra lines below are preserved ### line at the end. All content below it is preserved, ideal for custom content. .nens.toml and pyproject.toml are excluded, they don’t need it.

.nens.toml

The file for our own configuration. The defaults are below:

[meta]
# Version used to generate the config
meta_version = ''
# Project name (normally the name of the directory)
project_name = ''
# Whether we use python
uses_python = false
# Whether we have an ansible dir
uses_ansible = false

[pyprojecttoml]

[meta_workflow]
# Python version to use for linting and so
main_python_version = '3.12'

.editorconfig

The generated setup in .editorconfig automatically strips extra spaces at the end of lines and adds an enter at the end of the file. Indentation with spaces in most spaces. Suggested max line lengths for python&co, unlimited line lengths for markdown.

Nothing earth-shaking, just some basic sanity for all the files. See https://editorconfig.org/ .

Many editors have build-in support, for some you need a plugin, like for vscode.

.gitignore

Just a basic set of ignores.

pyproject.toml

The now-standard configuration file for python projects. Previously, most of the content would have been in setup.py and/or setup.cfg, but those aren’t needed anymore.

See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/ for the syntax.

There are many settings in this file, so nens-meta leaves it mostly alone so that you can have your own custom content in there. Many tools have their configuration in here:

In an empty project, nens-meta generates the following default settings:

# Initially generated by nens-meta

[tool.ruff]
target-version = "py310"

[tool.ruff.lint]
select = ["E4", "E7", "E9", "F", "I", "UP"]

[tool.zest-releaser]
release = false

There are three types of settings:

  • The settings not mentioned here: nens-meta doesn’t touch them, feel free to add and adjust them as needed.

  • The # Suggested by nens-meta settings. They should be present and nens-meta suggests a default value, but you’re free to change it.

  • The # Set by nens-meta settings. They’ll be overwritten when you let nens-meta update your project. So they’re governed by settings in .nens.toml.

    • project_name

    • package_name is used in several places where a list of the project’s package dirs with the source code in it is needed.

.pre-commit-config.yaml

By default, a few standard pre-commit checkers like trailing-whitespace and check-yaml are run. For python projects, Ruff is added.

.github/dependabot.yml

We want dependabot to keep our github actions up to date regarding the versions of the actions.

.github/workflows/meta_workflow.yml

A basic workflow that runs pre-commit. If it is a python project, also pytest is run.

If you’ve set [meta] > mimum_coverage in .nens.toml, the coverage is also generated and reported.

requirements.txt

We really need a line like -e .[test] in there.

requirements.yml

If you use ansible, you probably use modules like community.general. If Ansible-lint starts complaining , add such modules to `requirements.yml. An example:

# Extra ansible packages (used to get ansible-lint to find everything in
# github actions).
---
collections:
  - name: community.general
    version: ">=8.3.0"
  - name: ansible.posix