# psf/black

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/psf-black).**

41,395 stars · 2,723 forks · Python · mit

## Links

- GitHub: https://github.com/psf/black
- Homepage: https://black.readthedocs.io/en/stable/
- awesome-repositories: https://awesome-repositories.com/repository/psf-black.md

## Topics

`autopep8` `code` `codeformatter` `formatter` `gofmt` `hacktoberfest` `pre-commit-hook` `python` `yapf`

## Description

This project is an uncompromising, deterministic code formatter for Python. It functions by parsing source code into an abstract syntax tree and regenerating it according to a rigid, opinionated set of style rules. By automating the formatting process, it eliminates manual style debates and configuration overhead, ensuring that code remains consistent across entire projects regardless of the original input.

The tool distinguishes itself through its focus on speed and seamless integration into development workflows. It utilizes content-based file caching and parallel processing to maintain high performance on large codebases, while supporting version control hooks to enforce style consistency before code is committed. To preserve project history, it provides mechanisms to ignore specific commits in version control blame tracking, ensuring that automated style changes do not obscure original authorship.

Beyond standard source files, the formatter extends its capabilities to include Jupyter notebooks, type stubs, and embedded code examples within documentation. It offers broad compatibility through plugins for major text editors and integrated development environments, as well as support for the language server protocol. Configuration is managed through project-level files that are automatically discovered within the directory hierarchy, allowing for consistent behavior across diverse development environments.

## Tags

### Development Tools & Productivity

- [Code Formatters](https://awesome-repositories.com/f/development-tools-productivity/code-formatters.md) — Automatically enforces a strict, uniform style across source files.
- [Python Development Tools](https://awesome-repositories.com/f/development-tools-productivity/python-development-tools.md) — Provides an uncompromising, deterministic code formatter for the Python ecosystem. ([source](https://black.readthedocs.io/en/stable/))
- [Automated Formatting Frameworks](https://awesome-repositories.com/f/development-tools-productivity/automated-formatting-frameworks.md) — Enforces a consistent style across a codebase by automatically applying opinionated rules to source files.
- [Commit Hooks](https://awesome-repositories.com/f/development-tools-productivity/commit-hooks.md) — Enforces code quality by automatically running style checks on staged files before every commit. ([source](https://black.readthedocs.io/en/stable/integrations/source_version_control.html))
- [VS Code Extensions](https://awesome-repositories.com/f/development-tools-productivity/vs-code-extensions.md) — Automates code styling within VS Code via extensions. ([source](https://black.readthedocs.io/en/stable/integrations/editors.html))
- [Development Workflow Integrations](https://awesome-repositories.com/f/development-tools-productivity/development-workflow-integrations.md) — Connects automated styling tools directly into text editors and continuous integration pipelines.
- [Language Server Protocols](https://awesome-repositories.com/f/development-tools-productivity/language-server-protocols.md) — Connects code editors to formatting tools using standard protocols. ([source](https://black.readthedocs.io/en/stable/integrations/editors.html))
- [Git Hooks](https://awesome-repositories.com/f/development-tools-productivity/git-hooks.md) — Ensures only properly formatted code enters the repository history via pre-commit checks.
- [Import Sorters](https://awesome-repositories.com/f/development-tools-productivity/import-sorters.md) — Aligns import sorting behavior with project style guidelines. ([source](https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html))
- [Project Configuration Discovery](https://awesome-repositories.com/f/development-tools-productivity/project-configuration-discovery.md) — Defines project-specific formatting defaults and exclusion patterns in a configuration file that is automatically discovered. ([source](https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html))
- [Build Caches](https://awesome-repositories.com/f/development-tools-productivity/build-caches.md) — Stores results on disk to skip unmodified files and speed up workflows. ([source](https://black.readthedocs.io/en/stable/usage_and_configuration/file_collection_and_discovery.html))
- [Build Caching Systems](https://awesome-repositories.com/f/development-tools-productivity/build-caching-systems.md) — Stores hashes of processed files to skip redundant formatting operations and significantly improve performance on large codebases.
- [File Exclusion Rules](https://awesome-repositories.com/f/development-tools-productivity/file-exclusion-rules.md) — Allows preventing specific files or directories from being modified. ([source](https://black.readthedocs.io/en/stable/integrations/source_version_control.html))
- [Line Wrapping Engines](https://awesome-repositories.com/f/development-tools-productivity/line-wrapping-engines.md) — Wraps long lines of code by applying uniform whitespace rules and bracket-based indentation. ([source](https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html))
- [Version Control Ignore Parsers](https://awesome-repositories.com/f/development-tools-productivity/version-control-ignore-parsers.md) — Automatically skips files listed in version control ignore files. ([source](https://black.readthedocs.io/en/stable/usage_and_configuration/file_collection_and_discovery.html))
- [Version Control Utilities](https://awesome-repositories.com/f/development-tools-productivity/version-control-utilities.md) — Supports excluding specific commits from history tracking to preserve accurate code authorship during automated formatting. ([source](https://black.readthedocs.io/en/stable/guides/introducing_black_to_your_project.html))

### Programming Languages & Runtimes

- [Python Formatting Standards](https://awesome-repositories.com/f/programming-languages-runtimes/python-formatting-standards.md) — Applies opinionated style rules to Python source code, supporting customizable line lengths and target versions. ([source](https://black.readthedocs.io/en/stable/getting_started.html))
- [Source Code Parsers](https://awesome-repositories.com/f/programming-languages-runtimes/source-code-parsers.md) — Parses and reconstructs source code according to predefined syntactic rules.

### Data & Databases

- [Notebook Formatting Tools](https://awesome-repositories.com/f/data-databases/notebook-formatting-tools.md) — Applies consistent styling to Jupyter notebook files. ([source](https://black.readthedocs.io/en/stable/guides/using_black_with_jupyter_notebooks.html))
- [Notebook Automation Tools](https://awesome-repositories.com/f/data-databases/notebook-automation-tools.md) — Integrates notebook file processing into development workflows. ([source](https://black.readthedocs.io/en/stable/guides/using_black_with_jupyter_notebooks.html))
- [Notebook Formatters](https://awesome-repositories.com/f/data-databases/notebook-formatters.md) — Applies consistent styling to interactive notebook files to improve readability.

### Testing & Quality Assurance

- [Style Enforcement Suites](https://awesome-repositories.com/f/testing-quality-assurance/style-enforcement-suites.md) — Runs automated style checks during version control events to ensure consistent code quality without requiring manual environment setup. ([source](https://black.readthedocs.io/en/stable/integrations/github_actions.html))
