========
pyformat
========
.. image:: https://travis-ci.org/myint/pyformat.svg?branch=master
:target: https://travis-ci.org/myint/pyformat
:alt: Build status
*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:
.. code-block:: python
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:
.. code-block:: python
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()
.. _autoflake: https://github.com/myint/autoflake
.. _autopep8: https://github.com/hhatto/autopep8
.. _docformatter: https://github.com/myint/docformatter
.. _unify: https://github.com/myint/unify
Raw data
{
"_id": null,
"home_page": "https://github.com/myint/pyformat",
"name": "pyformat",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "beautify,code,format,formatter,reformat,style",
"author": "Steven Myint",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/f1/8c/e2e9b9f316839db401fd4efdd6199b98ba652636da6d982f9c0fb3dc1e9e/pyformat-1.0.tar.gz",
"platform": null,
"description": "========\npyformat\n========\n\n.. image:: https://travis-ci.org/myint/pyformat.svg?branch=master\n :target: https://travis-ci.org/myint/pyformat\n :alt: Build status\n\n*pyformat* formats Python code to follow a consistent style.\n\n\nFeatures\n========\n\n- Formats code to follow the PEP 8 style guide (using autopep8_).\n- Removes unused imports (using autoflake_).\n- Formats docstrings to follow PEP 257 (using docformatter_).\n- Makes strings all use the same type of quote where possible (using unify_).\n\n\nInstallation\n============\n\nFrom pip::\n\n $ pip install --upgrade pyformat\n\n\nExample\n=======\n\nAfter running::\n\n $ pyformat --in-place example.py\n\nThis code:\n\n.. code-block:: python\n\n def launch_rocket ():\n\n\n\n \"\"\"Launch\n the\n rocket. Go colonize space.\"\"\"\n\n def factorial(x):\n '''\n\n Return x factorial.\n\n This uses math.factorial.\n\n '''\n import math\n import re\n import os\n return math.factorial( x );\n def print_factorial(x):\n \"\"\"Print x factorial\"\"\"\n print( factorial(x) )\n def main():\n \"\"\"Main\n function\"\"\"\n print_factorial(5)\n if factorial(10):\n launch_rocket()\n\nGets formatted into this:\n\n.. code-block:: python\n\n def launch_rocket():\n \"\"\"Launch the rocket.\n\n Go colonize space.\n\n \"\"\"\n\n\n def factorial(x):\n \"\"\"Return x factorial.\n\n This uses math.factorial.\n\n \"\"\"\n import math\n return math.factorial(x)\n\n\n def print_factorial(x):\n \"\"\"Print x factorial.\"\"\"\n print(factorial(x))\n\n\n def main():\n \"\"\"Main function.\"\"\"\n print_factorial(5)\n if factorial(10):\n launch_rocket()\n\n\n.. _autoflake: https://github.com/myint/autoflake\n.. _autopep8: https://github.com/hhatto/autopep8\n.. _docformatter: https://github.com/myint/docformatter\n.. _unify: https://github.com/myint/unify\n",
"bugtrack_url": null,
"license": "Expat License",
"summary": "Formats Python code to follow a consistent style.",
"version": "1.0",
"project_urls": {
"Homepage": "https://github.com/myint/pyformat"
},
"split_keywords": [
"beautify",
"code",
"format",
"formatter",
"reformat",
"style"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f18ce2e9b9f316839db401fd4efdd6199b98ba652636da6d982f9c0fb3dc1e9e",
"md5": "865809fb1bd1d670934e75fb0e417944",
"sha256": "16376cbc7afb19d9cc3be024e2f3543dcec4d569716e8350c271dd04a1bbe393"
},
"downloads": -1,
"filename": "pyformat-1.0.tar.gz",
"has_sig": false,
"md5_digest": "865809fb1bd1d670934e75fb0e417944",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7391,
"upload_time": "2024-01-01T00:20:50",
"upload_time_iso_8601": "2024-01-01T00:20:50.453792Z",
"url": "https://files.pythonhosted.org/packages/f1/8c/e2e9b9f316839db401fd4efdd6199b98ba652636da6d982f9c0fb3dc1e9e/pyformat-1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-01 00:20:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "myint",
"github_project": "pyformat",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "pyformat"
}