The uncompromising Python code formatter

Overview

Black Logo

The Uncompromising Code Formatter

Actions Status Actions Status Documentation Status Coverage Status License: MIT PyPI Downloads conda-forge Code style: black

“Any color you like.”

Black is the uncompromising Python code formatter. By using it, you agree to cede control over minutiae of hand-formatting. In return, Black gives you speed, determinism, and freedom from pycodestyle nagging about formatting. You will save time and mental energy for more important matters.

Blackened code looks the same regardless of the project you're reading. Formatting becomes transparent after a while and you can focus on the content instead.

Black makes code review faster by producing the smallest diffs possible.

Try it out now using the Black Playground. Watch the PyCon 2019 talk to learn more.


Read the documentation on ReadTheDocs!


Installation and usage

Installation

Black can be installed by running pip install black. It requires Python 3.6.2+ to run. If you want to format Python 2 code as well, install with pip install black[python2]. If you want to format Jupyter Notebooks, install with pip install black[jupyter].

If you can't wait for the latest hotness and want to install from GitHub, use:

pip install git+git://github.com/psf/black

Usage

To get started right away with sensible defaults:

black {source_file_or_directory}

You can run Black as a package if running it as a script doesn't work:

python -m black {source_file_or_directory}

Further information can be found in our docs:

NOTE: This is a beta product

Black is already successfully used by many projects, small and big. Black has a comprehensive test suite, with efficient parallel tests, and our own auto formatting and parallel Continuous Integration runner. However, Black is still beta. Things will probably be wonky for a while. This is made explicit by the "Beta" trove classifier, as well as by the "b" in the version number. What this means for you is that until the formatter becomes stable, you should expect some formatting to change in the future. That being said, no drastic stylistic changes are planned, mostly responses to bug reports.

Also, as a safety measure which slows down processing, Black will check that the reformatted code still produces a valid AST that is effectively equivalent to the original (see the Pragmatism section for details). If you're feeling confident, use --fast.

The Black code style

Black is a PEP 8 compliant opinionated formatter. Black reformats entire files in place. Style configuration options are deliberately limited and rarely added. It doesn't take previous formatting into account (see Pragmatism for exceptions).

Our documentation covers the current Black code style, but planned changes to it are also documented. They're both worth taking a look:

Please refer to this document before submitting an issue. What seems like a bug might be intended behaviour.

Pragmatism

Early versions of Black used to be absolutist in some respects. They took after its initial author. This was fine at the time as it made the implementation simpler and there were not many users anyway. Not many edge cases were reported. As a mature tool, Black does make some exceptions to rules it otherwise holds.

Please refer to this document before submitting an issue just like with the document above. What seems like a bug might be intended behaviour.

Configuration

Black is able to read project-specific default values for its command line options from a pyproject.toml file. This is especially useful for specifying custom --include and --exclude/--force-exclude/--extend-exclude patterns for your project.

You can find more details in our documentation:

And if you're looking for more general configuration documentation:

Pro-tip: If you're asking yourself "Do I need to configure anything?" the answer is "No". Black is all about sensible defaults. Applying those defaults will have your code in compliance with many other Black formatted projects.

Used by

The following notable open-source projects trust Black with enforcing a consistent code style: pytest, tox, Pyramid, Django Channels, Hypothesis, attrs, SQLAlchemy, Poetry, PyPA applications (Warehouse, Bandersnatch, Pipenv, virtualenv), pandas, Pillow, Twisted, LocalStack, every Datadog Agent Integration, Home Assistant, Zulip, and many more.

The following organizations use Black: Facebook, Dropbox, Mozilla, Quora, Duolingo.

Are we missing anyone? Let us know.

Testimonials

Mike Bayer, author of SQLAlchemy:

I can't think of any single tool in my entire programming career that has given me a bigger productivity increase by its introduction. I can now do refactorings in about 1% of the keystrokes that it would have taken me previously when we had no way for code to format itself.

Dusty Phillips, writer:

Black is opinionated so you don't have to be.

Hynek Schlawack, creator of attrs, core developer of Twisted and CPython:

An auto-formatter that doesn't suck is all I want for Xmas!

Carl Meyer, Django core developer:

At least the name is good.

Kenneth Reitz, creator of requests and pipenv:

This vastly improves the formatting of our code. Thanks a ton!

Show your style

Use the badge in your project's README.md:

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

Using the badge in README.rst:

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/psf/black

Looks like this: Code style: black

License

MIT

Contributing

Welcome! Happy to see you willing to make the project better. You can get started by reading this:

You can also take a look at the rest of the contributing docs or talk with the developers:

Change log

The log has become rather long. It moved to its own file.

See CHANGES.

Authors

The author list is quite long nowadays, so it lives in its own file.

See AUTHORS.md

Code of Conduct

Everyone participating in the Black project, and in particular in the issue tracker, pull requests, and social media activity, is expected to treat other people with respect and more generally to follow the guidelines articulated in the Python Community Code of Conduct.

At the same time, humor is encouraged. In fact, basic familiarity with Monty Python's Flying Circus is expected. We are not savages.

And if you really need to slap somebody, do it with a fish while dancing.

Comments
  • Non-prerelease black release

    Non-prerelease black release

    It looks like Black is stable enough at the moment to release it as stable to PyPI. There are plenty of tools and integrations already which rely on black package and the fact that it is still in prerelease state sometime causes inconveniences, i.e. using it with pipenv forces allow_prereleases flag to be set to true.

    C: packaging C: maintenance 
    opened by lig 113
  • [Feature Request] Optimize imports

    [Feature Request] Optimize imports

    Can we please have a feature, similar to PyCharm's "optimize imports" feature, which basically sorts and removes un-used import statements?

    P.S. Great work!, Black works like a charm for me.

    T: enhancement help wanted 
    opened by devxpy 92
  • "INTERNAL ERROR: Black produced different code on the second pass of the formatter"

    • Version: 20.8b0
    • OS and Python version: all

    This is a rare problem that we're currently investigating. The most common case of it has to do with a combination of magic trailing commas and optional parentheses. Long story short, there's this behavior:

    • Black now treats all pre-existing trailing magic commas found in bracket pairs as signal to explode that bracket pair (e.g. to format it "one element per line");
    • in other places Black inserts trailing commas itself after reformatting a long expression or statement;
    • then on another run, Black finds those trailing commas and treats them as pre-existing trailing commas that signal that the given bracket pair should be exploded.

    The expected behavior is that there should be no difference between the first formatting and the second formatting. In practice Black sometimes chooses for or against optional parentheses differently depending on whether the line should be exploded or not. This is what needs fixing.

    Workaround

    We're working on fixing this, until then, format the file twice with --fast, it will keep its formatting moving forward.

    Call To Action

    If you find a case of this, please attach the generated log here so we can investigate. We've already added three identifying examples of this as expected failures to https://github.com/psf/black/pull/1627/commits/25206d8cc6e98143f0b10bcbe9e8b41b8b543abe.

    Finally, if you're interested in debugging this yourself, look for should_explode in if statements in the Black codebase. Those are the decisions that lead to unstable formatting.

    T: bug C: unstable formatting F: parentheses F: trailing comma 
    opened by ambv 80
  • Single quotes option

    Single quotes option

    Hi! Although Black now prefers doubles, can we have an option to keep single quotes? Forcing double quotes would make this great project unusable for many users who picked the rule of using single quotes.

    Operating system: MacOS Python version: 3.6 Black version: 18.4a0 Does also happen on master: yes

    T: design 
    opened by bofm 72
  • Black should have an opinion about doc strings

    Black should have an opinion about doc strings

    Operating system: Ubuntu 16.04 Python version: 3.6.1 Black version: master Does also happen on master: yes

    Hi,

    currently Black doesn't seem to have an opinion about doc strings or rather where the quotes should go.

    Black claims for this file for example that it is already formatted:

    def test():
        """This is one possibility.
    
        Very important stuff here.
        """
    
    
    def test2():
        """This is another one possibility.
    
        Very important stuff here."""
    
    
    def test3():
        """
        This is another one possibility.
    
        Very important stuff here.
        """
    
    
    def test4():
        """
        What about this?
        """
    
    
    def test5():
        """What about this?
    
        Some people also like to have an empty line at the end of the doc string.
    
        """
    

    The tool pydocstyle (in the spirit of PEP-0257) at least complains that the closing quotes should go on a separate line and if the docstring fits one line it should only span one line.

    It would be nice if that could be incorporated in Black as well.

    Thanks for the great work!

    Lukas.

    T: enhancement T: design 
    opened by Lukas0907 69
  • tweak collection literals to explode with trailing comma

    tweak collection literals to explode with trailing comma

    This is a change I discussed with @ambv at PyCon - the commit sequence should make things clear. I didn't go to the effort of fixing up existing tests (they'll fail a lot right now), but I can if this looks like a valid approach. This is somewhere between "proof of concept" and something I'd feel happy about, but I wanted feedback on how I'm tackling this early in development since I'm very much noideadog on this code.

    opened by durin42 65
  • Finish

    Finish "magic trailing comma" handling

    #826 introduced the concept of a magic trailing comma: if you, the programmer, explicitly put a trailing comma in a collection, it signals to Black that you want a given collection exploded into multiple lines, always. While this flies a bit in the way of "doesn't look at pre-existing formatting" and "non-configurability", it is extremely pragmatic and consistent with "make diffs as small as possible".

    However, there's issues with it so far. It doesn't yet work on nested collections. Worse yet, in those cases it leaves trailing commas behind when a collection ends up compressed into one line. We need to fix those edge cases to make it generally dependable.

    T: bug 
    opened by ambv 54
  • Black violates pep8 recommendation with long argument list

    Black violates pep8 recommendation with long argument list

    Currently, black reformats long routine names as follow

    # in:
    
    def very_important_function(template: str, *variables, file: os.PathLike, engine: str, header: bool = True, debug: bool = False):
        """Applies `variables` to the `template` and writes to `file`."""
        with open(file, 'w') as f:
            ...
    
    # out:
    
    def very_important_function(
        template: str,
        *variables,
        file: os.PathLike,
        engine: str,
        header: bool = True,
        debug: bool = False,
    ):
        """Applies `variables` to the `template` and writes to `file`."""
        with open(file, "w") as f:
    

    Desired style

    The current style done by black violates pep8 recommendation

    # Add 4 spaces (an extra level of indentation) to distinguish arguments from the rest.
    def long_function_name(
            var_one, var_two, var_three,
            var_four):
        print(var_one)
    

    The logic and motivation behind pep8 formatting, and against black, is that one wants to keep the indentation of the function definition continuation at a different level compared to the logic block. Otherwise, it's harder to differentiate what's one and what's the other, despite the indented frowny face.

    In fact, flake8 reports a pep8 violation for a case such as this

        if path.suffix in (
            '.js', '.json'
            ):
            proto = Protocol.json
    
    x.py:20:5: E125 continuation line with same indent as next logical line
    

    Black current formatting would be equivalent to this

        if path.suffix in (
            '.js', '.json'
        ):
            proto = Protocol.json
    

    Which we can probably all agree is a bad idea.

    Additional context from python-ideas mailing list

    T: design 
    opened by stefanoborini 54
  • Black does not honor exclude regex when files explicitly listed on the command line

    Black does not honor exclude regex when files explicitly listed on the command line

    Operating system: OSX Python version: 3.6.2 Black version: black, version 18.6b4

    The problem: certain directories in our repo contain generated python code that we don't want black to change. We've configure our repo to run black via pre-commit. Pre-commit invokes black with a list of changed files on the command line, and black's exclude regex does not work against those files and paths.

    i.e.

    black --exclude "/migrations/" content/migrations/0049_publicationstore_is_test.py
    reformatted content/migrations/0049_publicationstore_is_test.py
    All done! ✨ 🍰 ✨
    1 file reformatted.
    

    This makes us sad, since we've carefully put exclusion regexes into our pyproject.toml and black doesn't honor them when pre-commit calls it. Instead, we're having to workaround by configuring pre-commit to skip that path:

    repos:
    -   repo: https://github.com/ambv/black
        rev: stable
        hooks:
        - id: black
          language_version: python3.6
          exclude: migrations
    

    The behavior we'd like to see is that black's exclude regex would apply even when full file paths are listed on the commandline. I'd be happy to try for a PR if this seems like desirable behavior to anyone else...

    opened by adamehirsch 48
  • Fluent interfaces

    Fluent interfaces

    Operating system: Mac OS Python version: 3.6.4 Black version: 18.3a3 Does also happen on master: yes


    Black removes trailing backlashes, which can be used, for instance with yapf, to signal "don't join these line".

    This is problematic, for instance, if one uses the "fluent interface" idiom, which can lead to long chains of attribute accesses in a given expression.

    Here's an example:

    -        return sa.sql \
    -            .select([sa.sql.func.count(membership.c.user_id)]) \
    -            .where(membership.c.group_id == cls.id) \
    -            .group_by(membership.c.group_id) \
    -            .label('members_count')
    +        return sa.sql.select([sa.sql.func.count(membership.c.user_id)]).where(
    +            membership.c.group_id == cls.id
    +        ).group_by(
    +            membership.c.group_id
    +        ).label(
    +            'members_count'
    +        )
    

    The easiest solution would be to keep the line break in the presence of a backslash.

    T: enhancement help wanted 
    opened by sfermigier 43
  • Offer option other than pyproject.toml for config

    Offer option other than pyproject.toml for config

    https://github.com/pypa/pip/issues/6163 https://github.com/pypa/setuptools/issues/1642

    It seems that pyproject.toml is a trigger for enabling PEP 517 isolated builds. This seems a not good thing to tie to configuration of black. It broke pyinstaller and others with the pip-19.0 release.

    T: enhancement 
    opened by altendky 41
  • Bump sphinx from 5.3.0 to 6.0.0 in /docs

    Bump sphinx from 5.3.0 to 6.0.0 in /docs

    Bumps sphinx from 5.3.0 to 6.0.0.

    Release notes

    Sourced from sphinx's releases.

    v6.0.0

    Changelog: https://www.sphinx-doc.org/en/master/changes.html

    v6.0.0b2

    Changelog: https://www.sphinx-doc.org/en/master/changes.html

    v6.0.0b1

    Changelog: https://www.sphinx-doc.org/en/master/changes.html

    Changelog

    Sourced from sphinx's changelog.

    Release 6.0.0 (released Dec 29, 2022)

    Dependencies

    • #10468: Drop Python 3.6 support
    • #10470: Drop Python 3.7, Docutils 0.14, Docutils 0.15, Docutils 0.16, and Docutils 0.17 support. Patch by Adam Turner

    Incompatible changes

    • #7405: Removed the jQuery and underscore.js JavaScript frameworks.

      These frameworks are no longer be automatically injected into themes from Sphinx 6.0. If you develop a theme or extension that uses the jQuery, $, or $u global objects, you need to update your JavaScript to modern standards, or use the mitigation below.

      The first option is to use the sphinxcontrib.jquery_ extension, which has been developed by the Sphinx team and contributors. To use this, add sphinxcontrib.jquery to the extensions list in conf.py, or call app.setup_extension("sphinxcontrib.jquery") if you develop a Sphinx theme or extension.

      The second option is to manually ensure that the frameworks are present. To re-add jQuery and underscore.js, you will need to copy jquery.js and underscore.js from the Sphinx repository_ to your static directory, and add the following to your layout.html:

      .. code-block:: html+jinja

      {%- block scripts %} {{ super() }} {%- endblock %}

      .. _sphinxcontrib.jquery: https://github.com/sphinx-contrib/jquery/

      Patch by Adam Turner.

    • #10471, #10565: Removed deprecated APIs scheduled for removal in Sphinx 6.0. See :ref:dev-deprecated-apis for details. Patch by Adam Turner.

    • #10901: C Domain: Remove support for parsing pre-v3 style type directives and roles. Also remove associated configuration variables c_allow_pre_v3 and c_warn_on_allowed_pre_v3. Patch by Adam Turner.

    Features added

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    T: documentation C: dependencies skip news 
    opened by dependabot[bot] 1
  • Preview style: Crash on walrus in with statement

    Preview style: Crash on walrus in with statement

    This crashes in 23.1a1:

    async def f():
        with (x := await sleep(0)):
            pass
    

    Reported by @Zac-HD in https://github.com/psf/black/issues/3407#issuecomment-1364681511.

    T: bug F: parentheses C: preview style 
    opened by JelleZijlstra 1
  • Extra parentheses added even when string isn't split

    Extra parentheses added even when string isn't split

    Describe the bug With preview style, a long f-string where the only spaces are in the expression bit has parentheses added even though it isn't split over lines. For example:

    f(
        f'longstringwithnospacesinthestringbitbutwithspacesintheformattyfstringbithere{ 1 }',
    )
    

    becomes

    f(
        (
            f"longstringwithnospacesinthestringbitbutwithspacesintheformattyfstringbithere{ 1 }"
        ),
    )
    

    I would instead expect it not to have changed. See on black playground

    I noticed it also seems to occur with normal strings where the split is very near the start or end

    f(
        "l ongstringwithnospacesinthestringbitbutwithspacesintheformattyfstringbitherelollol",
    )
    

    becomes

    f(
        (
            "l ongstringwithnospacesinthestringbitbutwithspacesintheformattyfstringbitherelollol"
        ),
    )
    

    See on black playground Version Black 23.1a1, with --preview

    T: bug F: parentheses F: strings C: preview style 
    opened by wookie184 2
  • Black is not honoring #fmt: skip

    Black is not honoring #fmt: skip

    Describe the bug

    With below configuration in pyproject.toml :

    [tool.black]
    
    # How many characters per line to allow.
    line-length = 120
    
    # When processing Jupyter Notebooks, add the given magic to the list of known 
    # python-magics (timeit, prun, capture, pypy, python3, python, time). 
    # Useful for formatting cells with custom python magics.
    # python-cell-magics = 
    
    # Require a specific version of Black to be running 
    # (useful for unifying results across many environments e.g. with a pyproject.toml file). 
    # It can be either a major version number or an exact version.
    # required-version = 
    
    # A regular expression that matches files and directories that should be 
    # included on recursive searches. An empty value means all files are included 
    # regardless of the name. Use forward slashes for directories on all platforms (Windows, too). 
    # Exclusions are calculated first, inclusions later.
    # include = "(\.pyi?|\.ipynb)$"
    
    # A regular expression that matches files and directories that should be 
    # excluded on recursive searches. An empty value means no paths are excluded. 
    # Use forward slashes for directories on all platforms (Windows, too). 
    # Exclusions are calculated first, inclusions later.
    # exclude = "/(\.direnv|\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|venv|\.svn|\.ipynb_checkpoints|_build|buck-out|build|dist|__pypackages__)/"
    
    # Like 'exclude', but adds additional files and directories on top of the excluded ones.
    # (Useful if you simply want to add to the default).
    # extend-exclude = 
    
    # Like 'exclude', but files and directories matching this regex will be excluded 
    # even when they are passed explicitly as arguments.
    # force-exclude = 
    
    # The name of the file when passing it through stdin. 
    # Useful to make sure Black will respect 'force-exclude' option on some editors that rely on using stdin.
    # stdin-filename = 
    
    # Number of parallel workers. 
    # Can be a number or a range.
    # workers = 
    

    and this command line :

    black --config "pyproject.toml" --target-version py39 --check --diff .
    

    the following line of code is flagged :

    ave_quantity = self.exec_math(math_iterable["mean"], "mean", [])  # execute the "mean" fxn on the dataset  # cspell: disable-line # fmt: skip
    
    --- properties/datasets/models.py    2022-11-30 00:01:16.590743 +0000
    +++ properties/datasets/models.py    2022-11-30 00:01:18.692767 +0000
    @@ -746,11 +746,13 @@
             calculate the mean value of all the dataset points
     
             return: numerical value of this function when all variables are zero
             rtype: float
             """
    -        ave_quantity = self.exec_math(math_iterable["mean"], "mean", [])  # execute the "mean" fxn on the dataset # fmt:skip
    +        ave_quantity = self.exec_math(
    +            math_iterable["mean"], "mean", []
    +        )  # execute the "mean" fxn on the dataset # fmt:skip
             return getattr(ave_quantity, "magnitude", 0.0)
     
         def serialize(self, flat=False):
             return {
                 "type": "dataset",
    would reformat properties/datasets/models.py
    
    Oh no! 💥 💔 💥
    1 file would be reformatted, 102 files would be left unchanged.
    

    Which contradicts

    Black reformats entire files in place. It doesn’t reformat lines that end with # fmt: skip or blocks that start with # fmt: off and end with # fmt: on.

    Expected behavior

    Black should honor the directive # fmt: skip and ignore the flagged line of code.

    Environment

    • Black's version: 22.12.0
    • OS and Python version: Ubuntu 22.04.1 LTS/Python 3.9.16

    Additional context

    With directive #fmt:skip as the solely comment in the end of the line, black honors the directive and ignores the line of code.

    Related to

    • #451
    • #2024
    T: bug F: fmtskip 
    opened by ricardo-dematos 0
  • Black crashes with a single `# fmt: off` before a dict's closing bracket

    Black crashes with a single `# fmt: off` before a dict's closing bracket

    Describe the bug

    To Reproduce

    For example, take this code:

    dependencies = {
        a: b,
        # fmt: off
    }
    

    And run it with these arguments:

    $ black t.py
    

    The resulting error is:

    error: cannot format /Users/yileiyang/Downloads/t.py: Unable to match a closing bracket to the following opening bracket:
    
    Oh no! 💥 💔 💥
    1 file would fail to reformat.
    

    Expected behavior

    This is not a valid use of # fmt: off, but Black shouldn't crash either.

    Environment

    • Black's version: this crash existed since v22.1.0 in the stable style

    Additional context

    T: bug C: crash F: fmtoff 
    opened by yilei 0
Releases(23.1a1)
  • 23.1a1(Dec 18, 2022)

    This release provides a preview of Black's 2023 stable style. Black's default formatting style includes the following changes:

    • Enforce empty lines before classes and functions with sticky leading comments (#3302) (22.12.0)
    • Reformat empty and whitespace-only files as either an empty file (if no newline is present) or as a single newline character (if a newline is present) (#3348) (22.12.0)
    • Implicitly concatenated strings used as function args are now wrapped inside parentheses (#3307) (22.12.0)
    • Correctly handle trailing commas that are inside a line's leading non-nested parens (#3370) (22.12.0)
    • --skip-string-normalization / -S now prevents docstring prefixes from being normalized as expected (#3168) (since 22.8.0)
    • When using --skip-magic-trailing-comma or -C, trailing commas are stripped from subscript expressions with more than 1 element (#3209) (22.8.0)
    • Implicitly concatenated strings inside a list, set, or tuple are now wrapped inside parentheses (#3162) (22.8.0)
    • Fix a string merging/split issue when a comment is present in the middle of implicitly concatenated strings on its own line (#3227) (22.8.0)
    • Docstring quotes are no longer moved if it would violate the line length limit (#3044, #3430) (22.6.0)
    • Parentheses around return annotations are now managed (#2990) (22.6.0)
    • Remove unnecessary parentheses around awaited objects (#2991) (22.6.0)
    • Remove unnecessary parentheses in with statements (#2926) (22.6.0)
    • Remove trailing newlines after code block open (#3035) (22.6.0)
    • Code cell separators #%% are now standardised to # %% (#2919) (22.3.0)
    • Remove unnecessary parentheses from except statements (#2939) (22.3.0)
    • Remove unnecessary parentheses from tuple unpacking in for loops (#2945) (22.3.0)
    • Avoid magic-trailing-comma in single-element subscripts (#2942) (22.3.0)

    Please try it out and give feedback here: https://github.com/psf/black/issues/3407

    A stable 23.1.0 release will follow in January 2023.

    Source code(tar.gz)
    Source code(zip)
    black_linux(20.16 MB)
    black_macos(8.78 MB)
    black_windows.exe(8.92 MB)
  • 22.12.0(Dec 9, 2022)

    Preview style

    • Enforce empty lines before classes and functions with sticky leading comments (#3302)
    • Reformat empty and whitespace-only files as either an empty file (if no newline is present) or as a single newline character (if a newline is present) (#3348)
    • Implicitly concatenated strings used as function args are now wrapped inside parentheses (#3307)
    • Correctly handle trailing commas that are inside a line's leading non-nested parens (#3370)

    Configuration

    • Fix incorrectly applied .gitignore rules by considering the .gitignore location and the relative path to the target file (#3338)
    • Fix incorrectly ignoring .gitignore presence when more than one source directory is specified (#3336)

    Parser

    • Parsing support has been added for walruses inside generator expression that are passed as function args (for example, any(match := my_re.match(text) for text in texts)) (#3327).

    Integrations

    • Vim plugin: Optionally allow using the system installation of Black via let g:black_use_virtualenv = 0(#3309)
    Source code(tar.gz)
    Source code(zip)
    black_linux(20.16 MB)
    black_macos(8.78 MB)
    black_windows.exe(8.92 MB)
  • 22.10.0(Oct 6, 2022)

    22.10.0

    Highlights

    • Runtime support for Python 3.6 has been removed. Formatting 3.6 code will still be supported until further notice.

    Stable style

    • Fix a crash when # fmt: on is used on a different block level than # fmt: off (#3281)

    Preview style

    • Fix a crash when formatting some dicts with parenthesis-wrapped long string keys (#3262)

    Configuration

    • .ipynb_checkpoints directories are now excluded by default (#3293)
    • Add --skip-source-first-line / -x option to ignore the first line of source code while formatting (#3299)

    Packaging

    • Executables made with PyInstaller will no longer crash when formatting several files at once on macOS. Native x86-64 executables for macOS are available once again. (#3275)
    • Hatchling is now used as the build backend. This will not have any effect for users who install Black with its wheels from PyPI. (#3233)
    • Faster compiled wheels are now available for CPython 3.11 (#3276)

    Blackd

    • Windows style (CRLF) newlines will be preserved (#3257).

    Integrations

    • Vim plugin: add flag (g:black_preview) to enable/disable the preview style (#3246)
    • Update GitHub Action to support formatting of Jupyter Notebook files via a jupyter option (#3282)
    • Update GitHub Action to support use of version specifiers (e.g. <23) for Black version (#3265)
    Source code(tar.gz)
    Source code(zip)
    black_linux(16.43 MB)
    black_macos(6.93 MB)
    black_windows.exe(7.50 MB)
  • 22.8.0(Aug 31, 2022)

    Highlights

    • Python 3.11 is now supported, except for blackd as aiohttp does not support 3.11 as of publishing (#3234)
    • This is the last release that supports running Black on Python 3.6 (formatting 3.6 code will continue to be supported until further notice)
    • Reword the stability policy to say that we may, in rare cases, make changes that affect code that was not previously formatted by Black (#3155)

    Stable style

    • Fix an infinite loop when using # fmt: on/off in the middle of an expression or code block (#3158)
    • Fix incorrect handling of # fmt: skip on colon (:) lines (#3148)
    • Comments are no longer deleted when a line had spaces removed around power operators (#2874)

    Preview style

    • Single-character closing docstring quotes are no longer moved to their own line as this is invalid. This was a bug introduced in version 22.6.0. (#3166)
    • --skip-string-normalization / -S now prevents docstring prefixes from being normalized as expected (#3168)
    • When using --skip-magic-trailing-comma or -C, trailing commas are stripped from subscript expressions with more than 1 element (#3209)
    • Implicitly concatenated strings inside a list, set, or tuple are now wrapped inside parentheses (#3162)
    • Fix a string merging/split issue when a comment is present in the middle of implicitly concatenated strings on its own line (#3227)

    Blackd

    • blackd now supports enabling the preview style via the X-Preview header (#3217)

    Configuration

    • Black now uses the presence of debug f-strings to detect target version (#3215)
    • Fix misdetection of project root and verbose logging of sources in cases involving --stdin-filename (#3216)
    • Immediate .gitignore files in source directories given on the command line are now also respected, previously only .gitignore files in the project root and automatically discovered directories were respected (#3237)

    Documentation

    • Recommend using BlackConnect in IntelliJ IDEs (#3150)

    Integrations

    • Vim plugin: prefix messages with Black: so it's clear they come from Black (#3194)
    • Docker: changed to a /opt/venv installation + added to PATH to be available to non-root users (#3202)

    Output

    • Change from deprecated asyncio.get_event_loop() to create our event loop which removes DeprecationWarning (#3164)
    • Remove logging from internal blib2to3 library since it regularly emits error logs about failed caching that can and should be ignored (#3193)

    Parser

    • Type comments are now included in the AST equivalence check consistently so accidental deletion raises an error. Though type comments can't be tracked when running on PyPy 3.7 due to standard library limitations. (#2874)

    Performance

    • Reduce Black's startup time when formatting a single file by 15-30% (#3211)

    Full Changelog: https://github.com/psf/black/compare/22.6.0...22.8.0


    Thank you!

    • @hauntsaninja for modernizing our type annotations and fixing a few bugs too
    • @yilei for fixing our # fmt: off/on/skip code and continuing to improve the preview style, notably the (still) experimental string processing
    • The many community contributions to the non-core parts of the project:
      • @tobast for improving the QOL of the Vim plugin by simply appending Black: to most emitted messages
      • @Mogost for adding preview style support to blackd (finally :tada:)
      • @n-borges for improving the Docker image
      • @ionite34 for removing a hack in the official Black GitHub Action's start up code
    • @cooperlees for adding support for Python 3.11 and addressing DeprecationWarnings
    • @graingert for adding PyPy 3.8 to our CI matrix so we know Black works in even more places
    • @martinResearch for contributing a simple fix for such a silly and stupid .gitignore bug that we should've caught many moons ago
    • @fabioz for contributing the original patch that reduced the start up overhead when formatting a single file by 15-30% (!)

    ... and everyone else who contributed documentation, tests, or other improvements to the Black project!

    Finally congratulations to the first time contributors this time around!

    • @dmerejkowsky made their first contribution in https://github.com/psf/black/pull/3142
    • @m-aciek made their first contribution in https://github.com/psf/black/pull/3150
    • @Panther-12 made their first contribution in https://github.com/psf/black/pull/3167
    • @onescriptkid made their first contribution in https://github.com/psf/black/pull/3170
    • @tobast made their first contribution in https://github.com/psf/black/pull/3194
    • @n-borges made their first contribution in https://github.com/psf/black/pull/3202
    • @Mogost made their first contribution in https://github.com/psf/black/pull/3217
    • @ionite34 made their first contribution in https://github.com/psf/black/pull/3226
    • @martinResearch made their first contribution in https://github.com/psf/black/pull/3237
    Source code(tar.gz)
    Source code(zip)
    black_linux(16.43 MB)
    black_windows.exe(7.50 MB)
  • 22.6.0(Jun 28, 2022)

    Style

    • Fix unstable formatting involving #fmt: skip and # fmt:skip comments (notice the lack of spaces) (#2970)

    Preview style

    • Docstring quotes are no longer moved if it would violate the line length limit (#3044)
    • Parentheses around return annotations are now managed (#2990)
    • Remove unnecessary parentheses around awaited objects (#2991)
    • Remove unnecessary parentheses in with statements (#2926)
    • Remove trailing newlines after code block open (#3035)

    Integrations

    • Add scripts/migrate-black.py script to ease introduction of Black to a Git project (#3038)

    Output

    • Output Python version and implementation as part of --version flag (#2997)

    Packaging

    • Use tomli instead of tomllib on Python 3.11 builds where tomllib is not available (#2987)

    Parser

    • PEP 654 syntax (for example, except *ExceptionGroup:) is now supported (#3016)
    • PEP 646 syntax (for example, Array[Batch, *Shape] or def fn(*args: *T) -> None) is now supported (#3071)

    Vim Plugin

    • Fix strtobool function. It didn't parse true/on/false/off. (#3025)

    Full Changelog: https://github.com/psf/black/compare/22.3.0...22.6.0


    Thank you!

    • @jpy-git for improving our parentheses formatting significantly
    • @siuryan for fixing a fmt: skip bug, making it a little less annoying to use :)
    • @isidentical for implementing support for PEP 654 and 646 syntax
    • @defntvdm for fixing our vim plugin, especially as we (the maintainers) don't really know vim script sadly
    • @idorrington92 for fixing the docstring bug where Black would move the closing quotes causing it to violate the line length limit (whoops!)
    • @hbrunn for contributing the migrate-black script
    • @saroad2 for improving newline handling after code blocks and test infrastructure improvements

    ... and everyone else who contributed documentation, tests, or other improvements to the Black project!

    Finally congrats to first contributors!

    • @kolibril13 made their first contribution in https://github.com/psf/black/pull/2982
    • @siuryan made their first contribution in https://github.com/psf/black/pull/2970
    • @dignissimus made their first contribution in https://github.com/psf/black/pull/3007
    • @JiriKr made their first contribution in https://github.com/psf/black/pull/3023
    • @defntvdm made their first contribution in https://github.com/psf/black/pull/3025
    • @naveensrinivasan made their first contribution in https://github.com/psf/black/pull/3043
    • @idorrington92 made their first contribution in https://github.com/psf/black/pull/3044
    • @laundmo made their first contribution in https://github.com/psf/black/pull/3063
    • @ysk24ok made their first contribution in https://github.com/psf/black/pull/3070
    • @hbrunn made their first contribution in https://github.com/psf/black/pull/3038
    • @vivekvashist made their first contribution in https://github.com/psf/black/pull/3096
    • @nateprewitt made their first contribution in https://github.com/psf/black/pull/3125
    • @yilei made their first contribution in https://github.com/psf/black/pull/3135
    Source code(tar.gz)
    Source code(zip)
    black_linux(16.44 MB)
    black_macos(6.90 MB)
    black_windows.exe(7.47 MB)
  • 22.3.0(Mar 28, 2022)

    Preview style

    • Code cell separators #%% are now standardised to # %% (#2919)
    • Remove unnecessary parentheses from except statements (#2939)
    • Remove unnecessary parentheses from tuple unpacking in for loops (#2945)
    • Avoid magic-trailing-comma in single-element subscripts (#2942)

    Configuration

    • Do not format __pypackages__ directories by default (#2836)
    • Add support for specifying stable version with --required-version (#2832).
    • Avoid crashing when the user has no homedir (#2814)
    • Avoid crashing when md5 is not available (#2905)
    • Fix handling of directory junctions on Windows (#2904)

    Documentation

    • Update pylint config documentation (#2931)

    Integrations

    • Move test to disable plugin in Vim/Neovim, which speeds up loading (#2896)

    Output

    • In verbose, mode, log when Black is using user-level config (#2861)

    Packaging

    • Fix Black to work with Click 8.1.0 (#2966)
    • On Python 3.11 and newer, use the standard library's tomllib instead of tomli (#2903)
    • black-primer, the deprecated internal devtool, has been removed and copied to a separate repository (#2924)

    Parser

    • Black can now parse starred expressions in the target of for and async for statements, e.g for item in *items_1, *items_2: pass (#2879).
    Source code(tar.gz)
    Source code(zip)
    black_linux(17.03 MB)
    black_macos(7.26 MB)
    black_windows.exe(7.71 MB)
  • 22.1.0(Jan 29, 2022)

    At long last, Black is no longer a beta product! This is the first non-beta release and the first release covered by our new stability policy.

    Highlights

    • Remove Python 2 support (#2740)
    • Introduce the --preview flag (#2752)

    Style

    • Deprecate --experimental-string-processing and move the functionality under --preview (#2789)
    • For stubs, one blank line between class attributes and methods is now kept if there's at least one pre-existing blank line (#2736)
    • Black now normalizes string prefix order (#2297)
    • Remove spaces around power operators if both operands are simple (#2726)
    • Work around bug that causes unstable formatting in some cases in the presence of the magic trailing comma (#2807)
    • Use parentheses for attribute access on decimal float and int literals (#2799)
    • Don't add whitespace for attribute access on hexadecimal, binary, octal, and complex literals (#2799)
    • Treat blank lines in stubs the same inside top-level if statements (#2820)
    • Fix unstable formatting with semicolons and arithmetic expressions (#2817)
    • Fix unstable formatting around magic trailing comma (#2572)

    Parser

    • Fix mapping cases that contain as-expressions, like case {"key": 1 | 2 as password} (#2686)
    • Fix cases that contain multiple top-level as-expressions, like case 1 as a, 2 as b (#2716)
    • Fix call patterns that contain as-expressions with keyword arguments, like case Foo(bar=baz as quux) (#2749)
    • Tuple unpacking on return and yield constructs now implies 3.8+ (#2700)
    • Unparenthesized tuples on annotated assignments (e.g values: Tuple[int, ...] = 1, 2, 3) now implies 3.8+ (#2708)
    • Fix handling of standalone match() or case() when there is a trailing newline or a comment inside of the parentheses. (#2760)
    • from __future__ import annotations statement now implies Python 3.7+ (#2690)

    Performance

    • Speed-up the new backtracking parser about 4X in general (enabled when --target-version is set to 3.10 and higher). (#2728)
    • Black is now compiled with mypyc for an overall 2x speed-up. 64-bit Windows, MacOS, and Linux (not including musl) are supported. (#1009, #2431)

    Configuration

    • Do not accept bare carriage return line endings in pyproject.toml (#2408)
    • Add configuration option (python-cell-magics) to format cells with custom magics in Jupyter Notebooks (#2744)
    • Allow setting custom cache directory on all platforms with environment variable BLACK_CACHE_DIR (#2739).
    • Enable Python 3.10+ by default, without any extra need to specify --target-version=py310. (#2758)
    • Make passing SRC or --code mandatory and mutually exclusive (#2804)

    Output

    • Improve error message for invalid regular expression (#2678)
    • Improve error message when parsing fails during AST safety check by embedding the underlying SyntaxError (#2693)
    • No longer color diff headers white as it's unreadable in light themed terminals (#2691)
    • Text coloring added in the final statistics (#2712)
    • Verbose mode also now describes how a project root was discovered and which paths will be formatted. (#2526)

    Packaging

    • All upper version bounds on dependencies have been removed (#2718)
    • typing-extensions is no longer a required dependency in Python 3.10+ (#2772)
    • Set click lower bound to 8.0.0 as Black crashes on 7.1.2 (#2791)

    Integrations

    • Update GitHub action to support containerized runs (#2748)

    Documentation

    • Change protocol in pip installation instructions to https:// (#2761)
    • Change HTML theme to Furo primarily for its responsive design and mobile support (#2793)
    • Deprecate the black-primer tool (#2809)
    • Document Python support policy (#2819)

    Full Changelog: https://github.com/psf/black/compare/21.12b0...22.1.0


    Thank you!

    • @isidentical for their continued work on making our Python 3.10 support better than ever (we made them a co-maintainer :tada:)
    • @hauntsaninja for their help improving our stub style
    • @nipunn1313 making Black more stable (which has been a long running battle)
    • .. and all of my fellow co-maintainers who have made working on this project a wonderful ride @JelleZijlstra @cooperlees @felix-hilden @ambv @zsol

    And also congrats to first contributors!

    • @mwtoews made their first contribution in https://github.com/psf/black/pull/2701
    • @gunungpw made their first contribution in https://github.com/psf/black/pull/2733
    • @joshowen made their first contribution in https://github.com/psf/black/pull/2748
    • @Shivansh-007 made their first contribution in https://github.com/psf/black/pull/2526
    • @cbows made their first contribution in https://github.com/psf/black/pull/2761
    • @jlazar17 made their first contribution in https://github.com/psf/black/pull/2765
    • @VanSHOE made their first contribution in https://github.com/psf/black/pull/2712
    • @emfdavid made their first contribution in https://github.com/psf/black/pull/2786
    • @mgmarino made their first contribution in https://github.com/psf/black/pull/2744
    • @RHammond2 made their first contribution in https://github.com/psf/black/pull/2792
    • @percurnicus made their first contribution in https://github.com/psf/black/pull/2739
    • @sobolevn made their first contribution in https://github.com/psf/black/pull/2802
    Source code(tar.gz)
    Source code(zip)
    black_linux(17.03 MB)
    black_macos(7.23 MB)
    black_windows.exe(7.68 MB)
  • 21.12b0(Dec 5, 2021)

    Black

    • Fix determination of f-string expression spans (#2654)
    • Fix bad formatting of error messages about EOF in multi-line statements (#2343)
    • Functions and classes in blocks now have more consistent surrounding spacing (#2472)

    Jupyter Notebook support

    • Cell magics are now only processed if they are known Python cell magics. Earlier, all cell magics were tokenized, leading to possible indentation errors e.g. with %%writefile. (#2630)
    • Fix assignment to environment variables in Jupyter Notebooks (#2642)

    Python 3.10 support

    • Point users to using --target-version py310 if we detect 3.10-only syntax (#2668)
    • Fix match statements with open sequence subjects, like match a, b: or match a, *b: (#2639) (#2659)
    • Fix match/case statements that contain match/case soft keywords multiple times, like match re.match() (#2661)
    • Fix case statements with an inline body (#2665)
    • Fix styling of starred expressions inside match subject (#2667)
    • Fix parser error location on invalid syntax in a match statement (#2649)
    • Fix Python 3.10 support on platforms without ProcessPoolExecutor (#2631)
    • Improve parsing performance on code that uses match under --target-version py310 up to ~50% (#2670)

    Packaging

    • Remove dependency on regex (#2644) (#2663)

    Thank you!

    • @isidentical for the polishing up 3.10 syntax support (which they contributed in the first place!)
    • @MarcoGorelli for their ever-continuing work on Black's jupyter support
    • @jalaziz for cleaning up our Pyinstaller CD workflow
    • @hauntsaninja for helping us drop the regex dependency

    And also congrats to first contributors!

    • @MatthewScholefield made their first contribution in https://github.com/psf/black/pull/2631
    • @AshIsbitt made their first contribution in https://github.com/psf/black/pull/2632
    • @kalbasit made their first contribution in https://github.com/psf/black/pull/2638
    • @danieleades made their first contribution in https://github.com/psf/black/pull/2653
    • @danielsparing made their first contribution in https://github.com/psf/black/pull/2630
    • @tanvimoharir made their first contribution in https://github.com/psf/black/pull/2343
    Source code(tar.gz)
    Source code(zip)
    black_linux(16.92 MB)
    black_macos(7.19 MB)
    black_windows.exe(7.71 MB)
  • 21.11b1(Nov 18, 2021)

  • 21.11b0(Nov 17, 2021)

    Black

    • Warn about Python 2 deprecation in more cases by improving Python 2 only syntax detection (#2592)
    • Add experimental PyPy support (#2559)
    • Add partial support for the match statement. As it's experimental, it's only enabled when --target-version py310 is explicitly specified (#2586)
    • Add support for parenthesized with (#2586)
    • Declare support for Python 3.10 for running Black (#2562)

    Integrations

    • Fixed vim plugin with Python 3.10 by removing deprecated distutils import (#2610)
    • The vim plugin now parses skip_magic_trailing_comma from pyproject.toml (#2613)
    Source code(tar.gz)
    Source code(zip)
    black_linux(17.60 MB)
    black_macos(7.44 MB)
    black_windows.exe(7.93 MB)
  • 21.10b0(Nov 1, 2021)

    Black

    • Document stability policy, that will apply for non-beta releases (#2529)
    • Add new --workers parameter (#2514)
    • Fixed feature detection for positional-only arguments in lambdas (#2532)
    • Bumped typed-ast version minimum to 1.4.3 for 3.10 compatiblity (#2519)
    • Fixed a Python 3.10 compatibility issue where the loop argument was still being passed even though it has been removed (#2580)
    • Deprecate Python 2 formatting support (#2523)

    Blackd

    • Remove dependency on aiohttp-cors (#2500)
    • Bump required aiohttp version to 3.7.4 (#2509)

    Black-Primer

    • Add primer support for --projects (#2555)
    • Print primer summary after individual failures (#2570)

    Integrations

    • Allow to pass target_version in the vim plugin (#1319)
    • Install build tools in docker file and use multi-stage build to keep the image size down (#2582)
    Source code(tar.gz)
    Source code(zip)
    black_linux(17.61 MB)
    black_macos(7.43 MB)
    black_windows.exe(7.90 MB)
  • 21.9b0(Sep 14, 2021)

  • 21.8b0(Aug 29, 2021)

    Black

    • Add support for formatting Jupyter Notebook files (#2357)
    • Move from appdirs dependency to platformdirs (#2375)
    • Present a more user-friendly error if .gitignore is invalid (#2414)
    • The failsafe for accidentally added backslashes in f-string expressions has been hardened to handle more edge cases during quote normalization (#2437)
    • Avoid changing a function return type annotation's type to a tuple by adding a trailing comma (#2384)
    • Parsing support has been added for unparenthesized walruses in set literals, set comprehensions, and indices (#2447).
    • Pin setuptools-scm build-time dependency version (#2457)
    • Exclude typing-extensions version 3.10.0.1 due to it being broken on Python 3.10 (#2460)

    Blackd

    • Replace sys.exit(-1) with raise ImportError as it plays more nicely with tools that scan installed packages (#2440)

    Integrations

    • The provided pre-commit hooks no longer specify language_version to avoid overriding default_language_version (#2430)
    Source code(tar.gz)
    Source code(zip)
    black_linux(16.54 MB)
    black_macos(7.36 MB)
    black_windows.exe(7.89 MB)
  • 21.7b0(Jul 16, 2021)

    Black

    • Configuration files using TOML features higher than spec v0.5.0 are now supported (#2301)
    • Add primer support and test for code piped into black via STDIN (#2315)
    • Fix internal error when FORCE_OPTIONAL_PARENTHESES feature is enabled (#2332)
    • Accept empty stdin (#2346)
    • Provide a more useful error when parsing fails during AST safety checks (#2304)

    Docker

    • Add new latest_release tag automation to follow latest black release on docker images (#2374)

    Integrations

    • The vim plugin now searches upwards from the directory containing the current buffer instead of the current working directory for pyproject.toml. (#1871)
    • The vim plugin now reads the correct string normalization option in pyproject.toml (#1869)
    • The vim plugin no longer crashes Black when there's boolean values in pyproject.toml (#1869)
    Source code(tar.gz)
    Source code(zip)
    black_linux(16.35 MB)
    black_macos(7.30 MB)
    black_windows.exe(7.85 MB)
  • 21.6b0(Jun 10, 2021)

    Black

    • Fix failure caused by fmt: skip and indentation (#2281)
    • Account for += assignment when deciding whether to split string (#2312)
    • Correct max string length calculation when there are string operators (#2292)
    • Fixed option usage when using the --code flag (#2259)
    • Do not call uvloop.install() when Black is used as a library (#2303)
    • Added --required-version option to require a specific version to be running (#2300)
    • Fix incorrect custom breakpoint indices when string group contains fake f-strings (#2311)
    • Fix regression where R prefixes would be lowercased for docstrings (#2285)
    • Fix handling of named escapes (\N{...}) when --experimental-string-processing is used (#2319)
    Source code(tar.gz)
    Source code(zip)
    black_linux(16.47 MB)
    black_macos(7.12 MB)
    black_windows.exe(7.82 MB)
  • 21.5b2(May 31, 2021)

    Black

    • A space is no longer inserted into empty docstrings (#2249)
    • Fix handling of .gitignore files containing non-ASCII characters on Windows (#2229)
    • Respect .gitignore files in all levels, not only root/.gitignore file (apply .gitignore rules like git does) (#2225)
    • Restored compatibility with Click 8.0 on Python 3.6 when LANG=C used (#2227)
    • Add extra uvloop install + import support if in python env (#2258)
    • Fix --experimental-string-processing crash when matching parens are not found (#2283)
    • Make sure to split lines that start with a string operator (#2286)
    • Fix regular expression that black uses to identify f-expressions (#2287)

    Blackd

    • Add a lower bound for the aiohttp-cors dependency. Only 0.4.0 or higher is supported. (#2231)

    Packaging

    • Release self-contained x86_64 MacOS binaries as part of the GitHub release pipeline (#2198)
    • Always build binaries with the latest available Python (#2260)

    Documentation

    • Add discussion of magic comments to FAQ page (#2272)
    • --experimental-string-processing will be enabled by default in the future (#2273)
    • Fix typos discovered by codespell (#2228)
    • Fix Vim plugin installation instructions. (#2235)
    • Add new Frequently Asked Questions page (#2247)
    • Fix encoding + symlink issues preventing proper build on Windows (#2262)
    Source code(tar.gz)
    Source code(zip)
    black_linux(16.47 MB)
    black_macos(7.12 MB)
    black_windows.exe(7.82 MB)
  • 21.5b1(May 10, 2021)

  • 21.5b0(May 4, 2021)

  • 21.4b2(Apr 28, 2021)

  • 21.4b1(Apr 27, 2021)

    Black

    • Fix crash on docstrings ending with "\ ". (#2142)

    • Fix crash when atypical whitespace is cleaned out of dostrings (#2120)

    • Reflect the --skip-magic-trailing-comma and --experimental-string-processing flags in the name of the cache file. Without this fix, changes in these flags would not take effect if the cache had already been populated. (#2131)

    • Don't remove necessary parentheses from assignment expression containing assert / return statements. (#2143)

    Packaging

    • Bump pathspec to >= 0.8.1 to solve invalid .gitignore exclusion handling
    Source code(tar.gz)
    Source code(zip)
    black.elf(13.84 MB)
    black.exe(7.64 MB)
  • 21.4b0(Apr 25, 2021)

    Black

    • Fixed a rare but annoying formatting instability created by the combination of optional trailing commas inserted by Black and optional parentheses looking at pre-existing "magic" trailing commas. This fixes issue #1629 and all of its many many duplicates. (#2126)

    • Black now processes one-line docstrings by stripping leading and trailing spaces, and adding a padding space when needed to break up """". (#1740)

    • Black now cleans up leading non-breaking spaces in comments (#2092)

    • Black now respects --skip-string-normalization when normalizing multiline docstring quotes (#1637)

    • Black no longer removes all empty lines between non-function code and decorators when formatting typing stubs. Now Black enforces a single empty line. (#1646)

    • Black no longer adds an incorrect space after a parenthesized assignment expression in if/while statements (#1655)

    • Added --skip-magic-trailing-comma / -C to avoid using trailing commas as a reason to split lines (#1824)

    • fixed a crash when PWD=/ on POSIX (#1631)

    • fixed "I/O operation on closed file" when using --diff (#1664)

    • Prevent coloured diff output being interleaved with multiple files (#1673)

    • Added support for PEP 614 relaxed decorator syntax on python 3.9 (#1711)

    • Added parsing support for unparenthesized tuples and yield expressions in annotated assignments (#1835)

    • use lowercase hex strings (#1692)

    • added --extend-exclude argument (PR #2005)

    • speed up caching by avoiding pathlib (#1950)

    • --diff correctly indicates when a file doesn't end in a newline (#1662)

    • Added --stdin-filename argument to allow stdin to respect --force-exclude rules (#1780)

    • Lines ending with fmt: skip will now be not formatted (#1800)

    • PR #2053: Black no longer relies on typed-ast for Python 3.8 and higher

    • PR #2053: Python 2 support is now optional, install with python3 -m pip install black[python2] to maintain support.

    • Exclude venv directory by default (#1683)

    • Fixed "Black produced code that is not equivalent to the source" when formatting Python 2 docstrings (#2037)

    Packaging

    • Self-contained native Black binaries are now provided for releases via GitHub Releases (#1743)
    Source code(tar.gz)
    Source code(zip)
    black.elf(13.84 MB)
    black.exe(7.64 MB)
  • 20.8b1(Aug 26, 2020)

  • 20.8b0(Aug 26, 2020)

Helps working with singletons - things like global settings that you want to edit from the admin site.

Django Solo +---------------------------+ | | | | | \ | Django Solo helps

Sylvain Toé 726 Jan 08, 2023
A Django app to accept payments from various payment processors via Pluggable backends.

Django-Merchant Django-Merchant is a django application that enables you to use multiple payment processors from a single API. Gateways Following gate

Agiliq 997 Dec 24, 2022
Stream Framework is a Python library, which allows you to build news feed, activity streams and notification systems using Cassandra and/or Redis. The authors of Stream-Framework also provide a cloud service for feed technology:

Stream Framework Activity Streams & Newsfeeds Stream Framework is a Python library which allows you to build activity streams & newsfeeds using Cassan

Thierry Schellenbach 4.7k Jan 02, 2023
Automatically deletes old file for FileField and ImageField. It also deletes files on models instance deletion.

Django Cleanup Features The django-cleanup app automatically deletes files for FileField, ImageField and subclasses. When a FileField's value is chang

Ilya Shalyapin 838 Dec 30, 2022
Store model history and view/revert changes from admin site.

django-simple-history django-simple-history stores Django model state on every create/update/delete. This app supports the following combinations of D

Jazzband 1.8k Jan 08, 2023
Bleach is an allowed-list-based HTML sanitizing library that escapes or strips markup and attributes

Bleach Bleach is an allowed-list-based HTML sanitizing library that escapes or strips markup and attributes. Bleach can also linkify text safely, appl

Mozilla 2.5k Dec 29, 2022
Per object permissions for Django

django-guardian django-guardian is an implementation of per object permissions [1] on top of Django's authorization backend Documentation Online docum

3.3k Jan 04, 2023
Official Python agent for the Elastic APM

elastic-apm -- Elastic APM agent for Python This is the official Python module for Elastic APM. It provides full out-of-the-box support for many of th

elastic 369 Jan 05, 2023
Notes-Django: an advanced project to save notes in Django. where users are able to Create, Read, Update and Delete their notes.

An advanced software to keep you notes. It allows users to perform CRUD operations on theirs Notes. Was implemented Authorization and Authentication

Edilson Pateguana 1 Feb 05, 2022
Simple Login Logout System using Django, JavaScript and ajax.

Djanog-UserAuthenticationSystem Technology Use #version Python 3.9.5 Django 3.2.7 JavaScript --- Ajax Validation --- Login and Logout Functionality, A

Bhaskar Mahor 3 Mar 26, 2022
Store events and publish to Kafka

Create an event from Django ORM object model, store the event into the database and also publish it into Kafka cluster.

Diag 6 Nov 30, 2022
Use heroicons in your Django and Jinja templates.

heroicons Use heroicons in your Django and Jinja templates. Requirements Python 3.6 to 3.9 supported. Django 2.2 to 3.2 supported. Are your tests slow

Adam Johnson 52 Dec 14, 2022
Django React - Purity Dashboard (Open-Source) | AppSeed

Django React Purity Dashboard Start your Development with an Innovative Admin Template for Chakra UI and React. Purity UI Dashboard is built with over

App Generator 19 Sep 19, 2022
User Authentication In Django/Ajax/Jquery

User Authentication In Django/Ajax/Jquery Demo: Authentication System Using Django/Ajax/Jquery Demo: Authentication System Using Django Overview The D

Suman Raj Khanal 10 Mar 26, 2022
Zendesk Assignment - Django Based Ticket Viewer

Zendesk-Coding-Challenge Django Based Ticket Viewer The assignment has been made using Django. Important methods have been scripted in views.py. Excep

Akash Sampurnanand Pandey 0 Dec 23, 2021
Easily share data across your company via SQL queries. From Grove Collab.

SQL Explorer SQL Explorer aims to make the flow of data between people fast, simple, and confusion-free. It is a Django-based application that you can

Grove Collaborative 2.1k Dec 30, 2022
Updates redisearch instance with igdb data used for kimosabe

igdb-pdt Update RediSearch with IGDB games data in the following Format: { "game_slug": { "name": "game_name", "cover": "igdb_coverart_url",

6rotoms 0 Jul 30, 2021
Running in outer Django project folder (cd django_project)

Django Running in outer Django project folder (cd django_project) Make Migrations python manage.py makemigrations Migrate to Database python manage.py

1 Feb 07, 2022
Packs a bunch of smaller CSS files together from 1 folder.

Packs a bunch of smaller CSS files together from 1 folder.

1 Dec 09, 2021
This is a simple Todo web application built Django (back-end) and React JS (front-end)

Django REST Todo app This is a simple Todo web application built with Django (back-end) and React JS (front-end). The project enables you to systemati

Maxim Mukhin 5 May 06, 2022