Skip to main content

Formatter for functions

Project description

def-form

Python function definition formatter

Ruff PyPI PyPI Coverage Status

Overview

def-form is a code formatting tool that focuses specifically on Python function definitions. It helps maintain consistent formatting of function signatures by automatically organizing arguments vertically when they exceed specified thresholds.

Features

  • Automatic argument formatting: Converts inline function arguments to vertical format based on configurable rules
  • CI/CD integration: Provides both format and check commands for use in development pipelines
  • Configuration file support: Uses pyproject.toml for project-specific settings
  • Customizable thresholds: Control when arguments should be formatted vertically

Installation

pip install def-form

Usage

Format code

  • Format all Python files in a directory:
def-form format src/
  • Format a specific file:
def-form format my_module.py

Check code without formatting

  • Check if code follows formatting rules:
def-form check src/

Command line options

def-form format [OPTIONS] [PATH]

Options:
  --max-def-length INTEGER  Maximum length of function definition
  --max-inline-args INTEGER Maximum number of inline arguments
  --indent-size INTEGER     indent size in spaces (default: 4)
  --exclude TEXT            Paths or files to exclude from checking/formatting
  --show-skipped            Show skipped files/directories
  --config TEXT             Path to pyproject.toml configuration file

Configuration

Create a pyproject.toml file in your project root:

[tool.def-form]
max_def_length = 100
max_inline_args = 2
indent_size = 4
exclude = [
    '.venv',
    'migrations'
]

Configuration options

  • max_def_length: Maximum allowed characters in a single-line function definition
  • max_inline_args: Maximum number of arguments allowed in inline format
  • indent_size: Indent for arguments in spaces
  • exclude: Files or directories you want to exclude

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

def_form-0.1.0.tar.gz (57.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

def_form-0.1.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file def_form-0.1.0.tar.gz.

File metadata

  • Download URL: def_form-0.1.0.tar.gz
  • Upload date:
  • Size: 57.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for def_form-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f6aa07c7c6fccc291be9132b8b986ea017e00627b88250c02a2785704eb6e63b
MD5 df0aaddebc24f439dd27ae24c782b0e9
BLAKE2b-256 e14a64be90613ffb74938fdeeca056c908f8a70fde14fe4e7b697b68f245f2cb

See more details on using hashes here.

File details

Details for the file def_form-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: def_form-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for def_form-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0bd39168503cdec84e717257879d11f01e8e7c2e52b4a89355d81df97723c79
MD5 3341728bba944d28a877acb6e28e7eee
BLAKE2b-256 b4770113e2b29547653fc1ea612fff40addcaed39e3e53c0645ee4e2393fbace

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page