Skip to content

Examples

Python

include = ["config:black.toml", "config:mypy.toml", "config:ruff.toml"]

# Do not use setup.cfg
[[file_absent]]
file = "setup.cfg"

# Do not use setup.py
[[file_absent]]
file = "setup.py"

# Do not use requirements.txt
[[file_absent]]
file = "requirements.txt"

# use poetry as build tool
[[key_value_present]]
file = "pyproject.toml"
key.build-system.requires = ["poetry-core>=1.0.0"]
key.build-system.build-backend = "poetry.core.masonry.api"

# prevent from adding .venv and cache to git
[[lines_present]]
file = ".gitignore"
lines = "__pycache__"

[[lines_present]]
file = ".gitignore"
lines = ".cache"

[[lines_present]]
file = ".gitignore"
lines = ".venv"

Ruff

["pyproject.toml".key_value_present.tool.ruff]
line-length = 120
select = ["ALL"]
ignore = [
    "D",      # pydocstyle
    "ANN102", # Missing type annotation for {name} in classmethod
    "ANN101", # Missing type annotation for `self` in method
    "EM102",  # Exception must not use an f-string literal, assign to variable first
    "TCH",    # Use Type Checking Block
    "TRY003", # Avoid specifying long messages outside the exception class
    "EM",     # Error messages must not use string literal, must not use f-string
    "FBT",    # Do not use positional / default boolean arguments
]

["pyproject.toml".key_value_regex_match.tool.ruff]
target-version = "(py310)|(py311)"

["pyproject.toml".key_value_present.tool.ruff.per-file-ignores]
"tests/**" = [
    "S101",    # No usage of assert
    "INP",     # No implicit namespace packages
    "SLF",     # No private member accessed
    "ARG",     # unused arguments
    "PLR2004", # No usage of magic contants
    "ANN201",  # Missing return type annotation
]
"notebooks/**" = ["ALL"]

["pyproject.toml".key_value_present.tool.ruff.isort]
force-single-line = true

Black

[[key_value_present]]
file = "pyproject.toml"

[key_value_present.key.tool.black]
line-length = 120
exclude = "(/(notebooks|\\.git|\\.venv)/)"

[[entry_present]]
file = ".pre-commit-config.yaml"
key.repos = [
    { repo = "local", hooks = [
        { id = "black", name = "black", language = "system", entry = "poetry run black .", pass_filenames = false, always_run = true },
    ] },
]

Mypy

[[key_value_present]]
file = "pyproject.toml"

[key_value_present.key.tool.mypy]
explicit_package_bases = true
namespace_packages = true
ignore_missing_imports = true

[[entry_present]]
file = ".pre-commit-config.yaml"
entry.repos = [
    { repo = "local", hooks = [
        { id = "mypy", name = "mypy", language = "system", entry = "poetry run mypy dvb", pass_filenames = false, always_run = true },
    ] },
    { repo = "local", hooks = [
        { id = "mypy_on_tests", name = "mypy", language = "system", entry = "poetry run mypy tests", pass_filenames = false, always_run = true },
    ] },
]

[[lines_present]]
file = ".gitignore"
lines = ".mypy_cache"

Bashrc

[[file_present]]
file = ".bashrc"
regex = "export KEY=.*"