/configurator

Tool with configurations for the creation of better software

Primary LanguagePythonMIT LicenseMIT

configurator

Tool with configurations for the creation of better software.

Non-Python Tool Integrations

Autoformatters

ToolUsed Here?DescriptionInvocationNotes

prettier (docs)

Yes, >=3

Autoformatting files like JSON, Markdown, and YAML.

pre-commit hook mirror

Configure to use four space indent to match Python PEP 8.

toml-sort (docs)

Yes

Formatting TOML

pre-commit hook

pre-commit-hooks

Yes

Miscellaneous file cleanup like end of file newlines

pre-commit hook

When adding rules, try to avoid duplication of other tools like ruff.

sqlfluff (docs)

Yes

Autoformatting SQL

pre-commit hook

Linters

ToolUsed Here?DescriptionInvocationNotes

yamllint (docs)

Yes, >=1.33

Ensuring high quality YAML

pre-commit hook

Configure to coexist with YAML autoformatting of prettier.

codespell

Yes, >=2.3.0

Checking for typos

pre-commit hook

hadolint

Yes

Dockerfile following best practices

pre-commit hook

Markdown

ToolUsed Here?DescriptionInvocationNotes

markdown-toc-creator

Yes, >=0.0.8

Markdown table of contents

pre-commit hook

Python Tool Integrations

Autoformatters

ToolUsed Here?DescriptionInvocationNotes

black (docs)

Yes, >=24.2.0, jupyter extra

black code standard

pre-commit hook mirror

I am a fan of the hug_parens_with_braces_and_square_brackets preview option.

docformatter (docs)

Yes,>=1.7

Formatting docstrings

pre-commit hook

nb-clean

Yes,>=2.4

Cleaning Jupyter Notebooks

pre-commit hook

Paired with black[jupyter], this makes PRs with Jupyter Notebooks easier to read.

Testing

ToolUsed Here?DescriptionInvocationNotes

pytest (docs)

Yes

Test runner

Command line

pytest-xdist (docs)

Yes

Test runner parallelism via multiprocessing

pytest plugin

pytest-timer

Yes

Timing tests

pytest plugin

Use the colorama extra for colored output.

pytest-sugar

Yes

User-friendly pytest output

pytest plugin

pytest-subtests

Yes

Supporting subtesting

pytest plugin

Will be deprecated after pytest-dev/pytests-subtests#71.

pytest-rerunfailures

No

Easy decorator pytest.mark.flaky for flaky tests

pytest plugin

A third party alternative is flaky.

pytest-timeout

No

Terminate long-running tests

pytest plugin

Useful when there's unsolved race conditions.

pytest-recording

No

Cache HTTP requests as cassettes

pytest plugin

Maintained successor to pytest-vcr.

Linters

ToolUsed Here?DescriptionInvocationNotes

pylint (docs)

Yes, >=3

Static analysis

Command line

Since pylint is slow, pairing with the ruff partial reimplementation will ensure that pylint runs are more effective.

ruff (docs)

Yes,>=0.6

Static analysis

pre-commit hook mirror

Partially reimplements many other tools like flake8 and pylint.

refurb (docs)

Yes,>=2

Static analysis

Command line

refurb development outpaces its ruff reimplementation.

flake8 (docs)

Yes

Static analysis

pre-commit hook

Pair with Flake8-pyproject for configuration in pyproject.toml.

Mostly reimplemented by ruff, but still useful for partially reimplemented or not yet reimplemented plugins.

pydoclint (docs)

Yes

Checking docstrings

flake8 plugin

pydoclint was created in response to a stalled ruff reimplementation.

Type Checking

ToolUsed Here?DescriptionInvocationNotes

mypy (docs)

Yes, >=1.8

Static type checking

pre-commit hook mirror

Some opt-in rules like ignore-without-code and truthy-iterable are enabled.

typeguard (docs)

Yes

Runtime type checking

pytest plugin (built into typeguard), with --typeguard-packages=mypackage command line argument

beartype (docs)

No

Runtime type checking

pytest plugin pytest-beartype, with beartype_packages = "mypackage" configured

As of Feb. 20th in 2024, Python 3.10's typing.TypeAlias was unsupported.

mypy_clean_slate

No, >=0.2.5

Adopting mypy on a preexisting codebase

Command line

Equivalent of ruff --add-noqa, but for mypy.

Dependencies

ToolUsed Here?DescriptionInvocationNotes

Renovate (docs)

Yes

Automated dependency updates

GitHub Actions

Pair with renovate-config-validator, run via its pre-commit hook from https://github.com/renovatebot/pre-commit-hooks, to validate the configuration file.

uv (docs)

Yes, >=0.3.0

Python environment and dependency management

Command line

pip-compile from pip-tools (docs)

No, >=7.4.0

Requirements compilation

Command line

flake8-requirements

Yes

Checking requirements

flake8 plugin (CI only)

If invoking flake8 as part of pre-commit, run this only in CI because this check isn't relevant for most commits.

pipdeptree

No

Auditing requirements

Command line

Alternative to uv tree.

Packaging

ToolUsed Here?DescriptionInvocationNotes

validate-pyproject (docs)

Yes

Validating pyproject.toml configuration(s)

pre-commit hook

By specifying validate-pyproject-schema-store in additional_dependencies, configurations for mypy, ruff, uv, etc. will also be validated.

check-sdist

Yes

Checking SDist build

pre-commit hook

Unclear if this tool is a subset of build-and-inspect-python-package below.

build-and-inspect-python-package

No

Checking SDist, wheel, and README.

GitHub Actions

ini2toml (docs)

No

Migration from setup.cfg/ini to pyproject.toml

Command line

Helper Scripts

Changing Repos

a() {
    : Activate : Clone repository if needed, change to directory, and activating Python and Node.js environments
    repo=${1:-.}
    if [[ $repo != . ]]; then
        directory=$repo  # No renames currently in progress
        [[ -d $HOME/code/$directory ]] || git clone "git@github.com:Synthego/$repo.git" "$HOME/code/$directory";
        cd "$HOME/code/$directory" || return
    fi

    if [[ -n $PYENV_VIRTUAL_ENV ]]; then
        # shellcheck disable=SC1091
        . deactivate
    elif [[ -n $VIRTUAL_ENV ]]; then
        deactivate
    fi
    local venv=none
    if [[ -f .venv/bin/activate ]]; then
        venv=.venv
    elif [[ -f venv/bin/activate ]]; then
        venv=venv
    fi
    if [[ $venv != none ]]; then
        # shellcheck disable=SC1090,SC1091
        . $venv/bin/activate
        (python --version; type python | sed -E "s,^[^/]*(/.+)\),\1,") | xargs echo
    fi
}

.gitignore Creation

curl -s \
  https://raw.githubusercontent.com/github/gitignore/master/{Global/Vim,Global/JetBrains,Global/VisualStudioCode,Global/macOS,Python}.gitignore \
  > .gitignore