py-def-indent-formatter
A command line tool (and a pre-commit hook) to automatically format haning indentation in Python function definitions to 8 spaces.
Currently, this tool is only designed to work properly after your Python files have been formatted by black or blue.
Motivation of this tool
black and blue both use only 4 spaces as haning indentation in function definitions, which is not aligned with PEP8's recommendation.
Therefore, this tool specifically fixes this 4-space style choice of black and blue.
Installation
pip install format-def-indent
Usage
As a command line tool
To auto-format Python files (.py):
format-def-indent <PATH_THAT_CONTAINS_PYTHON_FILES>
Use --help to see documentations of command line arguments.
To auto-format Jupyter notebooks (.ipynb):
format-def-indent-in-jupyter <PATH_THAT_CONTAINS_PYTHON_FILES>
As a pre-commit hook
To auto-format Python files (.py), put the following into your .pre-commit-config.yaml file. Remember to replace <VERSION> with your version of this tool (such as v0.1.4):
- repo: https://github.com/cyyc1/py-def-indent-formatter
rev: <VERSION>
hooks:
- id: format-def-indent
To auto-format Jupyter notebooks (.ipynb), put the following into your .pre-commit-config.yaml file:
- repo: https://github.com/cyyc1/py-def-indent-formatter
rev: <VERSION>
hooks:
- id: format-def-indent-in-jupyter
See pre-commit for more instructions.
What does this formatter do
This tool formats the following "before" (red) into "after" (green).
Multi-line arguments in function definitions:
def some_function(
- arg1,
- arg2='test',
- *,
- arg3: int = 2,
- arg4: bool = False,
+ arg1,
+ arg2='test',
+ *,
+ arg3: int = 2,
+ arg4: bool = False,
) -> None:
print(1)
or
def some_functions(
- arg1,
- *args,
- **kwargs,
+ arg1,
+ *args,
+ **kwargs,
):
print(1)
Single-line arguments in function definitions:
def some_function(
- arg1, arg2='test', *, arg3: int = 2, arg4: bool = False,
+ arg1, arg2='test', *, arg3: int = 2, arg4: bool = False,
):
print(1)
Metadata
Release files for format-def-indent 0.1.7
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 |
|---|---|---|---|---|
| format_def_indent-0.1.7.tar.gz | 6.9 kB | Without provenance | Details for format_def_indent-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| format_def_indent-0.1.7-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for format_def_indent-0.1.7-py2.py3-none-any.whl |
Total release size: 15.4 kB
Release files / format_def_indent-0.1.7.tar.gz
| Download URL | format_def_indent-0.1.7.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a0fe4369449144f7c24c8726377a3feec2098d308b0e688269f04efac1a222f
|
|
BLAKE2b-256 checksum How to use checksums |
8446f117d5e88749b26ce7e2cdeb5e0bedeefceacc2f53cc742299a0793b5d1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.14
|
Release files / format_def_indent-0.1.7-py2.py3-none-any.whl
| Download URL | format_def_indent-0.1.7-py2.py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
295eb336b1a7f0481c556a1529b89de9a4ab01bd6fdc430f243e2f2104227835
|
|
BLAKE2b-256 checksum How to use checksums |
d9140557ba6225cc34b7fac716e6b6ddd340e0deed84eef3e9eb4f5b6fd2b3cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.14
|
Security for format-def-indent 0.1.7
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.