Giter Site home page Giter Site logo

life4 / awesome-python-code-formatters Goto Github PK

View Code? Open in Web Editor NEW
279.0 13.0 20.0 62 KB

A curated list of awesome Python code formatters

License: MIT License

Shell 100.00%
awesome python code-formatter black yapf gofmt formatter formatting isort qa

awesome-python-code-formatters's Introduction

Awesome Python Code Formatters

A curated list of awesome Python code formatters

All-in formatters

Formatters that take care of all your code.

  • autopep8: format Python code to conform to the PEP 8 style guide.
  • black: uncompromising Python code formatter.
  • ruff: fast Rust-powered linter and code formatter, for Python. The formatter is 100% compatible with Black.
  • yapf: yet another Python code formatter from Google.

UNIX-way formatters

Formatters that do only one job and do it well.

  • add-trailing-comma: adds trailing commas to calls and literals.
  • decrapify: some scripts that use pybowler.io for refactoring Python code.
  • docformatter: formats docstrings to follow PEP 257.
  • docstrfmt: a tool for automatically formatting reStructuredText in files and Python docstrings in a consistent way.
  • eradicate: removes commented-out code from Python files.
  • fix8: fixes some Python linting issues found by Flake8.
  • flynt: converts old string literal formatting to f-strings.
  • formate: a wrapper around isort and yapf with a few custom rules.
  • kwonly-transformer: Opinionated tool to ensure functions with multiple parameters to have exclusively keyword only parameters.
  • no-optional: Replace Optional[T] by Union[T, None].
  • pybetter: fixes some trivial problems with your code.
  • pydocstringformatter: Automatically format your Python docstrings to conform with PEP 8 and PEP 257.
  • pyment: formats and generates docstrings.
  • ssort: sorts and groups classes, functions, and methods.
  • Tornado Async Transformer: A libcst transformer for updating tornado @gen.coroutine syntax to python3.5+ native async/await.
  • teyit: formats unittest assertions.
  • unify: modifies strings to all use the same quote where possible.

Imports formatters

Formatters for import statements.

  • autoflake: removes unused imports and unused variables as reported by pyflakes.
  • isort: sorts imports.
  • pyall: keeps the __all__ list always up to date.
  • pycln: removes unused imports.
  • removestar: replaces import * in Python files with explicit imports.
  • reorder-python-imports: reorders imports.
  • unimport: removes unused imports.
  • usort: Safe, minimal import sorting for Python projects.

Upgrading tools

Tools to upgrade to newer versions of Python or a framework.

  • 2to3: translates Python 2 to 3.
  • auto-walrus: automatically use the walrus operator where possible.
  • com2ann: translates type comments to type annotations.
  • django-codemod: upgrades Django projects to newer version of the framework by automatically fixing deprecations.
  • django-upgrade: upgrades Django projects.
  • pyupgrade: upgrades syntax for newer versions of the language.

Improvements and wrappers

Wrappers for existing code formatters to make them more accessible.

  • black-macchiato: runs black on parts of the code.
  • blacken-docs: runs black on python code blocks in documentation files.
  • brunette: wrapper around black with improvements.
  • formate-black: integrates black with formate.
  • gray: wrapper around isort, pyupgrade, add-trailing-comma, and unify.
  • jupyterlab-code-formatter: code formatter for JupyterLab.
  • nbQA: run isort, pyupgrade, mypy, pylint, flake8, and more on Jupyter Notebooks.
  • pyformat: wrapper around autopep8, autoflake, docformatter, and unify.
  • shed: wrapper around autoflake, black, com2ann, isort, pybetter, pyupgrade, and teyit.

Libraries and refactoring

If you need to write your own formatter, these are libraries for you.

  • autotransform: framework for large-scale code modification.
  • bowler: safe code refactoring for modern Python.
  • fissix: backport of lib2to3, with enhancements.
  • importlab: A library that automatically infers dependencies for Python files. Importlab's main use case is to work with static analysis tools that process one file at a time, ensuring that a file's dependencies are analysed before it is.
  • libcst: parses Python code as a CST tree that keeps all formatting details (comments, whitespaces, parentheses, etc).
  • massedit: edit text files with Python.
  • refactor: AST-based fragmental source code refactoring toolkit.
  • rope: refactoring library.
  • semgrep: like grep but for code. Supports --autofix flag for simple replacement of matched code.
  • comby: Comby is a tool for searching and changing code structure

Code generators

This list doesn't contain tools that generate code, type annotations, comments etc. The difference is that code formatters transform your code from one form into another (which should be safe if the tool is stable) while code generators bring something totally new. If you're looking for code generators, check out the following links:

awesome-python-code-formatters's People

Contributors

cleder avatar dmytrolitvinov avatar franl08 avatar hadialqattan avatar isidentical avatar orsinium avatar petkostas avatar sobolevn avatar viragumathe5 avatar zac-hd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.