Formats Python code to follow a consistent style.
Project description
pyformat formats Python code to follow a consistent style.
Features
Formats code to follow the PEP 8 style guide (using autopep8).
Removes unused imports (using autoflake).
Formats docstrings to follow PEP 257 (using docformatter).
Makes strings all use the same type of quote where possible (using unify).
Installation
From pip:
$ pip install --upgrade pyformat
Example
After running:
$ pyformat --in-place example.py
This code:
def launch_rocket ():
"""Launch
the
rocket. Go colonize space."""
def factorial(x):
'''
Return x factorial.
This uses math.factorial.
'''
import math
import re
import os
return math.factorial( x );
def print_factorial(x):
"""Print x factorial"""
print( factorial(x) )
def main():
"""Main
function"""
print_factorial(5)
if factorial(10):
launch_rocket()
Gets formatted into this:
def launch_rocket():
"""Launch the rocket.
Go colonize space.
"""
def factorial(x):
"""Return x factorial.
This uses math.factorial.
"""
import math
return math.factorial(x)
def print_factorial(x):
"""Print x factorial."""
print(factorial(x))
def main():
"""Main function."""
print_factorial(5)
if factorial(10):
launch_rocket()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyformat-0.3.2.tar.gz
(7.2 kB
view details)
File details
Details for the file pyformat-0.3.2.tar.gz
.
File metadata
- Download URL: pyformat-0.3.2.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cf8c330d00b3625445b1eb15161cac361e513a0efdaf2e395106922f36534b6 |
|
MD5 | c07ea4f55770bb83f2f3f1d579d8dd6b |
|
BLAKE2b-256 | bded2a9fe3116dfc7831aba68ad5dd90706844f0ef34b7690d054babe1e4bf38 |