]> git.madduck.net Git - etc/vim.git/log

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

etc/vim.git
2 years agoImprove order of paragraphs on line splitting (#3270)
Tom Fryers [Thu, 15 Sep 2022 02:31:26 +0000 (03:31 +0100)]
Improve order of paragraphs on line splitting (#3270)

These two paragraphs were tucked away at the end of the section, after
the diversion on backslashes. I nearly missed the first paragraph and
opened a nonsense issue, and I think the second belongs higher up with
it too.

2 years agoFix a crash on dicts with paren-wrapped long string keys (#3262)
Yilei "Dolee" Yang [Wed, 14 Sep 2022 03:23:51 +0000 (20:23 -0700)]
Fix a crash on dicts with paren-wrapped long string keys (#3262)

Fix a crash when formatting some dicts with parenthesis-wrapped long
string keys. When LL[0] is an atom string, we need to check the atom
node's siblings instead of LL[0] itself, e.g.:

    dictsetmaker
      atom
        STRING '"This is a really long string that can\'t be expected to fit in one line and is used as a nested dict\'s key"'
      /atom
      COLON ':'
      atom
        LSQB ' ' '['
        listmaker
          STRING '"value"'
          COMMA ','
          STRING ' ' '"value"'
        /listmaker
        RSQB ']'
      /atom
      COMMA ','
    /dictsetmaker

2 years ago[FIX] migrate-black.py: don't fail on binary files (#3266)
Holger Brunn [Wed, 14 Sep 2022 03:06:54 +0000 (05:06 +0200)]
[FIX] migrate-black.py: don't fail on binary files (#3266)

2 years agoMove 3.11 tests to install aiohttp without C extensions (#3258)
Cooper Lees [Mon, 5 Sep 2022 22:27:39 +0000 (08:27 +1000)]
Move 3.11 tests to install aiohttp without C extensions (#3258)

* Move 311 tests to install aiohttp without C extensions

- Configure tox to install aiohttp without extensions
  - i.e. use `AIOHTTP_NO_EXTENSIONS=1` for pip install
  - This allows us to reenable blackd tests that use aiohttp testing helpers etc.
- Had to ignore `cgi` module deprecation warning
  - Filed issue for aiohttp to fix: https://github.com/aio-libs/aiohttp/issues/6905

Test:
- `/tmp/tb/bin/tox -e 311`

* Fix formatting + linting

* Add latest aiohttp for loop fix + Try to exempt deprecation warning but failed - will ask for help

* Remove unnecessary warning ignore

Co-authored-by: Cooper Ry Lees <me@wcooperlees.com>
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agoMitigate deprecation of aiohttp's `@middleware` decorator (#3259)
Richard Si [Mon, 5 Sep 2022 20:27:05 +0000 (16:27 -0400)]
Mitigate deprecation of aiohttp's `@middleware` decorator (#3259)

This is deprecated since aiohttp 4.0. If it doesn't exist just define a
no-op decorator that does nothing (after the other aiohttp imports
though!). By doing this, it's safe to ignore the DeprecationWarning
without needing to require the latest aiohttp once they remove
`@middleware`.

2 years agoAdd preview flag to Vim plugin (#3246)
PeterGrossmann [Thu, 1 Sep 2022 16:39:47 +0000 (18:39 +0200)]
Add preview flag to Vim plugin (#3246)

This allows the configuration of the --preview flag in the Vim plugin.

2 years agodocs: adds ExitStack alternative to future_style.md (#3247)
James Salvatore [Thu, 1 Sep 2022 04:25:13 +0000 (23:25 -0500)]
docs: adds ExitStack alternative to future_style.md (#3247)

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2 years agoPrepare docs for release 22.8.0 (#3248)
Richard Si [Wed, 31 Aug 2022 22:39:54 +0000 (18:39 -0400)]
Prepare docs for release 22.8.0 (#3248)

2 years agoUpdate stable branch after publishing to PyPI (#3223)
Richard Si [Wed, 31 Aug 2022 21:56:47 +0000 (17:56 -0400)]
Update stable branch after publishing to PyPI (#3223)

We've decided to a) convert stable back into a branch and b) to update
it immediately as part of the release process. We may as well automate
it. And about going back to a branch ...

Git tags are not the right tool, at all[^1]. They come with the
expectation that they will never change. Things will not work as
expected if they do change, doubly so if they change regularly. Once
you pull stable from the remote and it's copied in your local
repository, no matter how many times you run git pull you'll never see
it get updated automatically. Your only recourse is to delete the tag
via `git tag -d stable` before pulling.

This gets annoying really quickly since stable is supposed to be the
solution for folks "who want to move along as Black developers deem
the newest version reliable."[^2] See this comment for how this impacts
users using our Vim plugin[^3]. It also affects us developers[^4]. If
you have stable locally, once we cut a new release and update the stable
tag, a simple `git pull` / `git fetch` will not pull down the updated
stable tag. Unless you remember to delete stable before pulling, stable
will become stale and useless.

You can argue this is a good thing ("people should explicitly opt into
updating stable"), but IMO it does not match user expectations nor
developer expectations[^5]. Especially since not all our integrations
that use stable are bound by this security measure, for example our
GitHub Action (since it does a clean fetch of the repository every time
it's used). I believe consistency would be good here.

Finally, ever since we switched to a tag, we've been facing issues with
ReadTheDocs not picking up updates to stable unless we force a rebuild.
The initial rebuild on the stable update just pulls the commit the tag
previously pointed to. I'm not sure if switching back to a branch will
fix this, but I'd wager it will.

[^1]: https://git-scm.com/docs/git-tag#_on_re_tagging

[^2]: https://black.readthedocs.io/en/stable/contributing/release_process.html#moving-the-stable-tag

[^3]: https://github.com/psf/black/issues/2503#issuecomment-1196357379

[^4]: In fairness, most folks working on Black probably don't use the
      `stable` ref anyway, especially us maintainers who'd know what is
      the latest version by heart, but it'd still be nice to make it
      usable for local dev though.

[^5]: Also what benefit does a `stable` ref have over explicit version
      tags like `22.6.0`? If you're going to opt into some odd pin
      mechanism, might as well use explicit version tags for clarity
      and consistency.

2 years agoImprove & update release process to reflect recent changes (#3242)
Richard Si [Wed, 31 Aug 2022 21:46:48 +0000 (17:46 -0400)]
Improve & update release process to reflect recent changes (#3242)

- Formalise release cadence guidelines
- Overhaul release steps to be easier to follow and more thorough
- Reorder changelog template to something more sensible
- Update release automation docs to reflect recent improvements (notably
  the addition of in-repo mypyc wheel builds)

Co-authored-by: Felix Hildén <felix.hilden@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2 years agoUse .gitignore files in the initial source directories (#3237)
Martin de La Gorce [Wed, 31 Aug 2022 19:47:42 +0000 (20:47 +0100)]
Use .gitignore files in the initial source directories (#3237)

Solves https://github.com/psf/black/issues/2598 where Black wouldn't
use .gitignore at folder/.gitignore if you ran `black folder` for
example.

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agoUse strict mypy checking (#3222)
Shantanu [Wed, 31 Aug 2022 03:46:46 +0000 (20:46 -0700)]
Use strict mypy checking (#3222)

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agoAdd parens around implicit string concatenations where it increases readability ...
Yilei "Dolee" Yang [Wed, 31 Aug 2022 02:52:00 +0000 (19:52 -0700)]
Add parens around implicit string concatenations where it increases readability (#3162)

Adds parentheses around implicit string concatenations when it's inside
a list, set, or tuple. Except when it's only element and there's no trailing
comma.

Looking at the order of the transformers here, we need to "wrap in
parens" before string_split runs. So my solution is to introduce a
"collaboration" between StringSplitter and StringParenWrapper where the
splitter "skips" the split until the wrapper adds the parens (and then
the line after the paren is split by StringSplitter) in another pass.

I have also considered an alternative approach, where I tried to add a
different "string paren wrapper" class, and it runs before string_split.
Then I found out it requires a different do_transform implementation
than StringParenWrapper.do_transform, since the later assumes it runs
after the delimiter_split transform. So I stopped researching that
route.

Originally function calls were also included in this change, but given
missing commas should usually result in a runtime error and the scary
amount of changes this cause on downstream code, they were removed in
later revisions.

2 years agoDelay worker count determination
Richard Si [Sat, 13 Aug 2022 17:46:52 +0000 (13:46 -0400)]
Delay worker count determination

os.cpu_count() can return None (sounds like a super arcane edge case
though) so the type annotation for the `workers` parameter of
`black.main` is wrong. This *could* technically cause a runtime
TypeError since it'd trip one of mypyc's runtime type checks so we
might as well fix it.

Reading the documentation (and cross-checking with the source code),
you are actually allowed to pass None as `max_workers` to
`concurrent.futures.ProcessPoolExecutor`. If it is None, the pool
initializer will simply call os.cpu_count() [^1] (defaulting to 1 if it
returns None [^2]). It'll even round down the worker count to a level
that's safe for Windows.

... so theoretically we don't even need to call os.cpu_count()
ourselves, but our Windows limit is 60 (unlike the stdlib's 61) and I'd
prefer not accidentally reintroducing a crash on machines with many,
many CPU cores.

[^1]: https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.ProcessPoolExecutor
[^2]: https://github.com/python/cpython/blob/a372a7d65320396d44e8beb976e3a6c382963d4e/Lib/concurrent/futures/process.py#L600

2 years agoLoad .gitignore and exclude regex at time of use
Richard Si [Fri, 5 Aug 2022 18:04:43 +0000 (14:04 -0400)]
Load .gitignore and exclude regex at time of use

Loading .gitignore and compiling the exclude regex can take more than
15ms. We shouldn't and don't need to pay this cost if we're simply
formatting files given on the command line directly.

I would've loved to lazily import pathspec, but the patch won't be clean
until the file collection and discovery logic is refactored first.

Co-authored-by: Fabio Zadrozny <fabiofz@gmail.com>
2 years agoLazily import parallelized format modules
Richard Si [Thu, 4 Aug 2022 00:18:33 +0000 (20:18 -0400)]
Lazily import parallelized format modules

`black.reformat_many` depends on a lot of slow-to-import modules. When
formatting simply a single file, the time paid to import those modules
is totally wasted. So I moved `black.reformat_many` and its helpers
to `black.concurrency` which is now *only* imported if there's more
than one file to reformat. This way, running Black over a single file
is snappier

Here are the numbers before and after this patch running `python -m
black --version`:

- interpreted: 411 ms +- 9 ms -> 342 ms +- 7 ms: 1.20x faster
- compiled: 365 ms +- 15 ms -> 304 ms +- 7 ms: 1.20x faster

Co-authored-by: Fabio Zadrozny <fabiofz@gmail.com>
2 years agoFix misdetection of project root with `--stdin-filename` (#3216)
Shantanu [Fri, 26 Aug 2022 21:07:25 +0000 (14:07 -0700)]
Fix misdetection of project root with `--stdin-filename` (#3216)

There are a number of places this behaviour could be patched, for
instance, it's quite tempting to patch it in `get_sources`. However
I believe we generally have the invariant that project root contains all
files we want to format, in which case it seems prudent to keep that
invariant.

This also improves the accuracy of the "sources to be formatted" log
message with --stdin-filename.

Fixes GH-3207.

2 years agoRemove hacky subprocess call in action.yml (#3226)
Ionite [Fri, 26 Aug 2022 19:45:31 +0000 (15:45 -0400)]
Remove hacky subprocess call in action.yml (#3226)

Updates action.yml to use the alternative $GITHUB_ACTION_PATH variable
instead of the original ${{ github.action_path }} which caused issues
with bash on the Windows runners. This removes the need for a Python
subprocess to call the main.py script.

2 years agoFix a string merging/split issue caused by standalone comments. (#3227)
Yilei "Dolee" Yang [Tue, 23 Aug 2022 03:40:38 +0000 (20:40 -0700)]
Fix a string merging/split issue caused by standalone comments. (#3227)

Fixes #2734: a standalone comment causes strings to be merged into one far too long (and requiring two passes to do so).

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agoAdd passing 3.11 CI by exempting blackd tests (#3234)
Cooper Lees [Tue, 23 Aug 2022 03:39:48 +0000 (20:39 -0700)]
Add passing 3.11 CI by exempting blackd tests (#3234)

- Had to exempt blackd tests for now due to aiohttp
  - Skip by using `sys.version_info` tuple
  - aiohttp does not compile in 3.11 yet - refer to #3230
- Add a deadsnakes ubuntu workflow to run 3.11-dev to ensure we don't regress
  - Have it also format ourselves

Test:
- `tox -e 311`

Co-authored-by: Cooper Ry Lees <me@wcooperlees.com>
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agoUpdate email (#3235)
Alexander Huynh [Sat, 20 Aug 2022 17:45:20 +0000 (13:45 -0400)]
Update email (#3235)

This file gets scraped a lot, so create a distinct email for potential
spam.

2 years agoStrip trailing commas in subscripts with -C (#3209)
Shantanu [Sat, 13 Aug 2022 13:41:34 +0000 (06:41 -0700)]
Strip trailing commas in subscripts with -C (#3209)

Fixes #2296, #3204

2 years agoPort & upstream mypyc wheel build workflow (#3197)
Richard Si [Sat, 13 Aug 2022 03:33:17 +0000 (23:33 -0400)]
Port & upstream mypyc wheel build workflow  (#3197)

2 years agoadd preview option support for blackd (#3217)
Alexandr Artemyev [Sat, 13 Aug 2022 03:23:02 +0000 (09:23 +0600)]
add preview option support for blackd (#3217)

Fixes #3195

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agoUse --no-implicit-optional for type checking (#3220)
Shantanu [Sat, 13 Aug 2022 02:28:47 +0000 (19:28 -0700)]
Use --no-implicit-optional for type checking (#3220)

This makes type checking PEP 484 compliant (as of 2018).
mypy will change its defaults soon.

See:
https://github.com/python/mypy/issues/9091
https://github.com/python/mypy/pull/13401

2 years agoUse debug f-strings for feature detection (#3215)
Shantanu [Wed, 10 Aug 2022 21:29:47 +0000 (14:29 -0700)]
Use debug f-strings for feature detection (#3215)

Fixes GH-2907.

2 years agoRemove invalid syntax in docstrings -S --preview test (#3205)
Tom Fryers [Tue, 2 Aug 2022 21:22:04 +0000 (22:22 +0100)]
Remove invalid syntax in docstrings -S --preview test (#3205)

uR is not a legal string prefix, so this test breaks (AssertionError:
cannot use --safe with this file; failed to parse source file AST:
invalid syntax) if changed to one in which the file is changed. I've
changed the last test to have u alone, and added an R to the test above
instead.

2 years agomakes install available for all users in docker image (#3202)
Nicolò Intrieri [Tue, 2 Aug 2022 16:01:15 +0000 (18:01 +0200)]
makes install available for all users in docker image (#3202)

* makes install available for all users in docker image

moves the installation path from /root/.local to a
virtualenv. this way we still get the lightweight
multistage build without excluding non-root users.

* adds changelog entry for docker-image fix

A changelog entry has been added under the Integration
subheader

* changes dockerfile to use the venv activate script

we are now using the inbuilt venv activate script, as well
as explicitly mentioning the binary location in the entrypoint
cmd.

Co-authored-by: Nicolò <nicolo.intrieri@spinforward.it>
Co-authored-by: Cooper Lees <me@cooperlees.com>
2 years agoBump sphinx from 5.1.0 to 5.1.1 in /docs (#3201)
dependabot[bot] [Mon, 1 Aug 2022 17:51:46 +0000 (13:51 -0400)]
Bump sphinx from 5.1.0 to 5.1.1 in /docs (#3201)

Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 5.1.0 to 5.1.1.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/5.x/CHANGES)
- [Commits](https://github.com/sphinx-doc/sphinx/compare/v5.1.0...v5.1.1)

---
updated-dependencies:
- dependency-name: sphinx
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoMove fuzz.py to scripts/ (#3199)
Richard Si [Sun, 31 Jul 2022 14:34:29 +0000 (10:34 -0400)]
Move fuzz.py to scripts/ (#3199)

2 years agoAdd sanity check to executable CD + more (#3190)
Richard Si [Sat, 30 Jul 2022 03:38:39 +0000 (23:38 -0400)]
Add sanity check to executable CD + more (#3190)

Building executables without any testing is quite sketchy, let's at
least verify they won't crash on startup and format Black's own
codebase.

Also replaced "binaries" with "executables" since it's clearer and
won't be confused with mypyc.

Finally, I added colorama so all Windows users can get colour.

2 years agoRemove blib2to3 grammar cache logging (#3193)
Richard Si [Sat, 30 Jul 2022 03:28:43 +0000 (23:28 -0400)]
Remove blib2to3 grammar cache logging (#3193)

As error logs are emitted often (they happen when Black's cache
directory is created after blib2to3 tries to write its cache) and cause
issues to be filed by users who think Black isn't working correctly.

These errors are expected for now and aren't a cause for concern so
let's remove them to stop worrying users (and new issues from being
opened). We can improve the blib2to3 caching mechanism to write its
cache at the end of a successful command line invocation later.

2 years agoVim plugin: prefix messages with "Black: " (#3194)
Théophile Bastian [Thu, 28 Jul 2022 23:49:00 +0000 (01:49 +0200)]
Vim plugin: prefix messages with "Black: " (#3194)

As mentioned in GH-3185, when using Black as a Vim plugin, especially
automatically on save, the plugin's messages can be confusing, as
nothing indicates that they come from Black.

2 years agoConsolidate test CI and add concurrency limits (#3189)
Richard Si [Thu, 28 Jul 2022 20:55:36 +0000 (16:55 -0400)]
Consolidate test CI and add concurrency limits (#3189)

2 years agoBump pre-commit hooks (#3191)
Richard Si [Thu, 28 Jul 2022 02:04:14 +0000 (22:04 -0400)]
Bump pre-commit hooks (#3191)

2 years agoReformat codebase with isort
Richard Si [Wed, 27 Jul 2022 01:33:08 +0000 (21:33 -0400)]
Reformat codebase with isort

2 years agoAdd isort to linting toolchain
Richard Si [Wed, 27 Jul 2022 01:32:31 +0000 (21:32 -0400)]
Add isort to linting toolchain

Co-authored-by: Shivansh-007 <shivansh-007@outlook.com>
2 years agoBump sphinx from 5.0.2 to 5.1.0 in /docs (#3183)
dependabot[bot] [Wed, 27 Jul 2022 00:51:32 +0000 (20:51 -0400)]
Bump sphinx from 5.0.2 to 5.1.0 in /docs (#3183)

Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 5.0.2 to 5.1.0.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/5.x/CHANGES)
- [Commits](https://github.com/sphinx-doc/sphinx/compare/v5.0.2...v5.1.0)

---
updated-dependencies:
- dependency-name: sphinx
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoUse underscores instead of a space in a test file's name (#3180)
Yilei "Dolee" Yang [Wed, 20 Jul 2022 01:33:00 +0000 (18:33 -0700)]
Use underscores instead of a space in a test file's name (#3180)

... for *consistency*

2 years agoFix an infinite loop when using `# fmt: on/off` ... (#3158)
Yilei "Dolee" Yang [Wed, 20 Jul 2022 00:57:23 +0000 (17:57 -0700)]
Fix an infinite loop when using `# fmt: on/off` ... (#3158)

... in the middle of an expression or code block by adding a missing return.

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2 years agoFix the handling of `# fmt: skip` when it's at a colon line (#3148)
Yilei "Dolee" Yang [Tue, 19 Jul 2022 21:26:11 +0000 (14:26 -0700)]
Fix the handling of `# fmt: skip` when it's at a colon line (#3148)

When the Leaf node with `# fmt: skip` is a NEWLINE inside a `suite`
Node, the nodes to ignore should be from the siblings of the parent
`suite` Node.

There is a also a special case for the ASYNC token, where it expands
to the grandparent Node where the ASYNC token is.

This fixes GH-2646, GH-3126, GH-2680, GH-2421, GH-2339, and GH-2138.

2 years agoImprove warning filtering in tests (#3175)
Thomas Grainger [Tue, 19 Jul 2022 02:17:13 +0000 (03:17 +0100)]
Improve warning filtering in tests (#3175)

2 years agoAdd pypy-3.8 to test matrix (#3174)
Thomas Grainger [Sun, 17 Jul 2022 01:55:46 +0000 (02:55 +0100)]
Add pypy-3.8 to test matrix (#3174)

2 years agoconfigure strict pytest and filterwarnings=['error', ... (#3173)
Thomas Grainger [Sat, 16 Jul 2022 12:18:55 +0000 (13:18 +0100)]
configure strict pytest and filterwarnings=['error', ... (#3173)

* configure strict pytest

* ignore current warnings

2 years agoFix typo in config docs for --extend-exclude (#3170)
onescriptkid [Thu, 14 Jul 2022 23:51:18 +0000 (16:51 -0700)]
Fix typo in config docs for --extend-exclude (#3170)

The old regex in the example was invalid and caused an error on startup.

2 years agoActually disable docstring prefix normalization with -S + fix instability (#3168)
Richard Si [Thu, 14 Jul 2022 23:47:33 +0000 (19:47 -0400)]
Actually disable docstring prefix normalization with -S + fix instability (#3168)

The former was a regression I introduced a long time ago. To avoid
changing the stable style too much, the regression is only fixed if
--preview is enabled

Annoyingly enough, as we currently always enforce a second format pass if
changes were made, there's no good way to prove the existence of the
docstring quote normalization instability issue. For posterity, here's
one failing example:

    --- source
    +++ first pass
    @@ -1,7 +1,7 @@
     def some_function(self):
    -    ''''<text here>
    +    """ '<text here>

         <text here, since without another non-empty line black is stable>

    -    '''
    +    """
         pass
    --- first pass
    +++ second pass
    @@ -1,7 +1,7 @@
     def some_function(self):
    -    """ '<text here>
    +    """'<text here>

         <text here, since without another non-empty line black is stable>

         """
         pass

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2 years agoMove to explicitly creating a new loop (#3164)
Cooper Lees [Thu, 14 Jul 2022 22:24:34 +0000 (15:24 -0700)]
Move to explicitly creating a new loop (#3164)

* Move to explicitly creating a new loop

- >= 3.10 add a warning that `get_event_loop` will not automatically create a loop
- Move to explicit API

Test:
- `python3.11 -m venv --upgrade-deps /tmp/tb`
  - `/tmp/tb/bin/pip install -e .`
  - Install deps and no blackd as aiohttp + yarl can't build still with 3.11
  - https://github.com/aio-libs/aiohttp/issues/6600
- `export PYTHONWARNINGS=error`
```
cooper@l33t:~/repos/black$ /tmp/tb/bin/black .
All done! ✨ 🍰 ✨
44 files left unchanged.
```

Fixes #3110

* Add to CHANGES.md

* Fix a cooper typo yet again

* Set default asyncio loop to our explicitly created one + unset on exit

* Update CHANGES.md

Fix my silly typo.

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: Cooper Ry Lees <me@wcooperlees.com>
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
2 years agoAdd warning to not run blackd publicly in docs (#3167)
Nimrod [Thu, 14 Jul 2022 19:22:29 +0000 (22:22 +0300)]
Add warning to not run blackd publicly in docs (#3167)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2 years agoDon't (ever) put a single-char closing docstring quote on a new line (#3166)
Richard Si [Thu, 14 Jul 2022 02:26:05 +0000 (22:26 -0400)]
Don't (ever) put a single-char closing docstring quote on a new line (#3166)

Doing so is invalid. Note this only fixes the preview style since the
logic putting closing docstring quotes on their own line if they violate
the line length limit is quite new.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2 years agoCopy over comments when hugging power ops (#2874)
Richard Si [Thu, 14 Jul 2022 00:02:51 +0000 (20:02 -0400)]
Copy over comments when hugging power ops  (#2874)

Otherwise they'd be deleted which was a regression in 22.1.0 (oops! my
bad!). Also type comments are now tracked in the AST safety check on all
compatible platforms to error out if this happens again.

Overall the line rewriting code has been rewritten to do "the right
thing (tm)", I hope this fixes other potential bugs in the code (fwiw I
got to drop the bugfix in blib2to3.pytree.Leaf.clone since now bracket
metadata is properly copied over).

Fixes #2873

2 years agoRecommend using BlackConnect in IntelliJ IDEs (#3150)
Maciej Olko [Mon, 11 Jul 2022 16:27:51 +0000 (18:27 +0200)]
Recommend using BlackConnect in IntelliJ IDEs (#3150)

* Recommend using BlackConnect in IntelliJ IDEs

* IntelliJ IDEs integration docs: improve formatting

* Add changelog for recommending BlackConnect

* IntelliJ IDEs integration docs: improve formatting

* Apply suggestions from code review

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
* Fix indentation

* Apply italic to Black name

Consequently with other places in the document

* Move CHANGELOG entry to Unreleased section

* IntelliJ IDEs integration docs: bring back a point with formatting a file

* IntelliJ IDEs integration docs: fix extra whitespace and linebreak

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agoStability policy: permit exceptional changes for unformatted code (#3155)
Jelle Zijlstra [Wed, 6 Jul 2022 17:33:07 +0000 (10:33 -0700)]
Stability policy: permit exceptional changes for unformatted code (#3155)

2 years agoUse RTD's new build process and config (#3149)
Jakub Kuczys [Sun, 3 Jul 2022 20:47:18 +0000 (22:47 +0200)]
Use RTD's new build process and config (#3149)

See the deprecation notice:
https://docs.readthedocs.io/en/stable/config-file/v2.html#python-version

2 years agoFix typo in CHANGES.md (#3142)
Dimitri Merejkowsky [Tue, 28 Jun 2022 07:44:55 +0000 (09:44 +0200)]
Fix typo in CHANGES.md (#3142)

2 years agoPrepare docs for release 22.6.0 (#3139)
Richard Si [Tue, 28 Jun 2022 00:33:35 +0000 (20:33 -0400)]
Prepare docs for release 22.6.0 (#3139)

2 years agoUpdate preview style docs to include recent changes (#3136)
Felix Hildén [Mon, 27 Jun 2022 20:24:34 +0000 (23:24 +0300)]
Update preview style docs to include recent changes (#3136)

Covers GH-2926, GH-2990, GH-2991, and GH-3035.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agoBump furo from 2022.6.4.1 to 2022.6.21 in /docs (#3138)
dependabot[bot] [Mon, 27 Jun 2022 13:54:49 +0000 (09:54 -0400)]
Bump furo from 2022.6.4.1 to 2022.6.21 in /docs (#3138)

Bumps [furo](https://github.com/pradyunsg/furo) from 2022.6.4.1 to 2022.6.21.
- [Release notes](https://github.com/pradyunsg/furo/releases)
- [Changelog](https://github.com/pradyunsg/furo/blob/main/docs/changelog.md)
- [Commits](https://github.com/pradyunsg/furo/compare/2022.06.04.1...2022.06.21)

---
updated-dependencies:
- dependency-name: furo
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoOnly call get_future_imports when needed (#3135)
Yilei "Dolee" Yang [Thu, 23 Jun 2022 19:41:05 +0000 (12:41 -0700)]
Only call get_future_imports when needed (#3135)

2 years agoBump sphinx from 5.0.1 to 5.0.2 in /docs (#3128)
dependabot[bot] [Mon, 20 Jun 2022 14:22:24 +0000 (10:22 -0400)]
Bump sphinx from 5.0.1 to 5.0.2 in /docs (#3128)

Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 5.0.1 to 5.0.2.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/5.x/CHANGES)
- [Commits](https://github.com/sphinx-doc/sphinx/compare/v5.0.1...v5.0.2)

---
updated-dependencies:
- dependency-name: sphinx
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoReplace link to Requests documentation (#3125)
Nate Prewitt [Fri, 17 Jun 2022 19:37:33 +0000 (13:37 -0600)]
Replace link to Requests documentation (#3125)

2 years agoTest run black on self (#3114)
Sagi Shadur [Tue, 14 Jun 2022 16:08:36 +0000 (19:08 +0300)]
Test run black on self (#3114)

* Add run_self environment in tox

* Add run_self task as part of the lint CI flow

* Remove hard coded sources list

* Remove black from pre-commit

Co-authored-by: Cooper Lees <me@cooperlees.com>
2 years agoBump actions/setup-python from 3 to 4 (#3121)
Hugo van Kemenade [Mon, 13 Jun 2022 14:02:39 +0000 (17:02 +0300)]
Bump actions/setup-python from 3 to 4 (#3121)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years agoUse is_number_token instead of assertion (#3069)
Marco Edward Gorelli [Sat, 11 Jun 2022 16:04:09 +0000 (17:04 +0100)]
Use is_number_token instead of assertion (#3069)

2 years agoUpdate documentation dependencies (#3118)
Richard Si [Sat, 11 Jun 2022 15:44:01 +0000 (11:44 -0400)]
Update documentation dependencies (#3118)

Furo, myst-parser, and Sphinx (had to pin docutils due to sphinx breakage)

2 years agoRemove newline after code block open (#3035)
Sagi Shadur [Sat, 11 Jun 2022 06:55:01 +0000 (09:55 +0300)]
Remove newline after code block open (#3035)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2 years agoBump pre-commit/action from 2.0.3 to 3.0.0 (#3108)
dependabot[bot] [Sat, 11 Jun 2022 00:29:32 +0000 (20:29 -0400)]
Bump pre-commit/action from 2.0.3 to 3.0.0 (#3108)

Bumps [pre-commit/action](https://github.com/pre-commit/action) from 2.0.3 to 3.0.0.
- [Release notes](https://github.com/pre-commit/action/releases)
- [Commits](https://github.com/pre-commit/action/compare/v2.0.3...v3.0.0)

---
updated-dependencies:
- dependency-name: pre-commit/action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoFix minor typo (#3096)
Vivek Vashist [Fri, 3 Jun 2022 22:59:26 +0000 (08:29 +0930)]
Fix minor typo (#3096)

2 years agoAdd script to ease migration to black (#3038)
Holger Brunn [Wed, 1 Jun 2022 18:20:02 +0000 (20:20 +0200)]
Add script to ease migration to black (#3038)

* Add script to ease migration to black

* Update CHANGES.md

Co-authored-by: Cooper Lees <me@cooperlees.com>
2 years agoImplement support for PEP 646 (#3071)
Batuhan Taskaya [Thu, 26 May 2022 16:45:22 +0000 (19:45 +0300)]
Implement support for PEP 646 (#3071)

2 years agoAdd more examples to exclude files in addition to the defaults (#3070)
Yusuke Nishioka [Thu, 26 May 2022 14:44:26 +0000 (23:44 +0900)]
Add more examples to exclude files in addition to the defaults (#3070)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2 years agoDocument new Microsoft Black Formatter extension for VSCode (#3063)
laundmo [Sat, 21 May 2022 20:18:06 +0000 (22:18 +0200)]
Document new Microsoft Black Formatter extension for VSCode (#3063)

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agoRemove hard coded test cases (#3062)
Sagi Shadur [Wed, 18 May 2022 19:11:37 +0000 (22:11 +0300)]
Remove hard coded test cases (#3062)

2 years agoBump docker/setup-buildx-action from 1 to 2 (#3058)
dependabot[bot] [Tue, 10 May 2022 02:22:01 +0000 (22:22 -0400)]
Bump docker/setup-buildx-action from 1 to 2 (#3058)

Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 1 to 2.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/v1...v2)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoBump docker/login-action from 1 to 2 (#3059)
dependabot[bot] [Tue, 10 May 2022 02:13:12 +0000 (22:13 -0400)]
Bump docker/login-action from 1 to 2 (#3059)

Bumps [docker/login-action](https://github.com/docker/login-action) from 1 to 2.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/v1...v2)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoBump docker/build-push-action from 2 to 3 (#3057)
dependabot[bot] [Tue, 10 May 2022 02:11:29 +0000 (22:11 -0400)]
Bump docker/build-push-action from 2 to 3 (#3057)

Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 2 to 3.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoBump docker/setup-qemu-action from 1 to 2 (#3056)
dependabot[bot] [Tue, 10 May 2022 02:08:56 +0000 (22:08 -0400)]
Bump docker/setup-qemu-action from 1 to 2 (#3056)

Bumps [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action) from 1 to 2.
- [Release notes](https://github.com/docker/setup-qemu-action/releases)
- [Commits](https://github.com/docker/setup-qemu-action/compare/v1...v2)

---
updated-dependencies:
- dependency-name: docker/setup-qemu-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoRead simple data cases automatically (#3034)
Sagi Shadur [Sun, 8 May 2022 19:27:40 +0000 (22:27 +0300)]
Read simple data cases automatically (#3034)

Co-authored-by: Felix Hildén <felix.hilden@gmail.com>
2 years agoPut closing quote on a separate line if docstring is too long (#3044)
Iain Dorrington [Sun, 8 May 2022 04:34:28 +0000 (05:34 +0100)]
Put closing quote on a separate line if docstring is too long (#3044)

Fixes #1632

Co-authored-by: Felix Hildén <felix.hilden@gmail.com>
2 years agoDocs: clarify fmt:on/off requirements (#2985) (#3048)
Felix Hildén [Sun, 8 May 2022 00:58:10 +0000 (03:58 +0300)]
Docs: clarify fmt:on/off requirements (#2985) (#3048)

2 years agoMove imports of `ThreadPoolExecutor` into `reformat_many()`, allowing Black-in-the...
Zac Hatfield-Dodds [Fri, 6 May 2022 14:06:27 +0000 (07:06 -0700)]
Move imports of `ThreadPoolExecutor` into `reformat_many()`, allowing Black-in-the-browser (#3046)

This is a slight perf win for use-cases that don't invoke `reformat_many()`, but more importantly to me today it means I can use Black in pyscript.

2 years agochore: Set permissions for GitHub actions (#3043)
Naveen [Tue, 3 May 2022 13:08:33 +0000 (08:08 -0500)]
chore: Set permissions for GitHub actions (#3043)

Restrict the GitHub token permissions only to the required ones; this way, even if the attackers will succeed in compromising your workflow, they won’t be able to do much.

- Included permissions for the action. https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions

https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs

[Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/)

Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.github.com>
2 years agoBump myst-parser from 0.16.1 to 0.17.2 in /docs (#3019)
dependabot[bot] [Mon, 2 May 2022 17:12:23 +0000 (11:12 -0600)]
Bump myst-parser from 0.16.1 to 0.17.2 in /docs (#3019)

Bumps [myst-parser](https://github.com/executablebooks/MyST-Parser) from 0.16.1 to 0.17.2.
- [Release notes](https://github.com/executablebooks/MyST-Parser/releases)
- [Changelog](https://github.com/executablebooks/MyST-Parser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/executablebooks/MyST-Parser/compare/v0.16.1...v0.17.2)

---
updated-dependencies:
- dependency-name: myst-parser
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoStop pinning lark-parser (#3041)
Cooper Lees [Thu, 28 Apr 2022 16:27:16 +0000 (10:27 -0600)]
Stop pinning lark-parser (#3041)

- Latest version works more

Test: `tox -e fuzz`

2 years agoFix strtobool function (#3025)
Vadim Nikolaev [Thu, 28 Apr 2022 15:17:23 +0000 (20:17 +0500)]
Fix strtobool function (#3025)

* Fix strtobool function for vim plugin
* Update CHANGES.md

Co-authored-by: Cooper Lees <me@cooperlees.com>
2 years agoUpdated Black Docker Hub link in docs (#3023)
JiriKr [Thu, 21 Apr 2022 19:55:56 +0000 (21:55 +0200)]
Updated Black Docker Hub link in docs (#3023)

Fixes #3022

2 years agoSupport 3.11 / PEP 654 syntax (#3016)
Batuhan Taskaya [Fri, 15 Apr 2022 16:25:07 +0000 (19:25 +0300)]
Support 3.11 / PEP 654 syntax (#3016)

2 years agoMake ipynb tests compatible with ipython 8.3.0+ (#3008)
Marco Edward Gorelli [Wed, 13 Apr 2022 23:13:33 +0000 (00:13 +0100)]
Make ipynb tests compatible with ipython 8.3.0+ (#3008)

2 years agoQuote black[jupyter] and black[d] in installation docs (#3006)
Jelle Zijlstra [Mon, 11 Apr 2022 23:25:46 +0000 (16:25 -0700)]
Quote black[jupyter] and black[d] in installation docs (#3006)

We just got someone on Discord who was confused because the command as
written caused their shell to try to do command expansion.

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agoBump furo from 2022.3.4 to 2022.4.7 in /docs (#3003)
dependabot[bot] [Mon, 11 Apr 2022 23:24:00 +0000 (19:24 -0400)]
Bump furo from 2022.3.4 to 2022.4.7 in /docs (#3003)

Bumps [furo](https://github.com/pradyunsg/furo) from 2022.3.4 to 2022.4.7.
- [Release notes](https://github.com/pradyunsg/furo/releases)
- [Changelog](https://github.com/pradyunsg/furo/blob/main/docs/changelog.md)
- [Commits](https://github.com/pradyunsg/furo/compare/2022.03.04...2022.04.07)

---
updated-dependencies:
- dependency-name: furo
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoQuote "black[jupyter]" in README.md (#3007)
Sam Ezeh [Mon, 11 Apr 2022 22:10:46 +0000 (23:10 +0100)]
Quote "black[jupyter]" in README.md (#3007)

2 years agoBump actions/upload-artifact from 2 to 3 (#3004)
dependabot[bot] [Mon, 11 Apr 2022 21:26:28 +0000 (17:26 -0400)]
Bump actions/upload-artifact from 2 to 3 (#3004)

Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2 to 3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoExplain our use of mypyc in the FAQ (#3002)
Richard Si [Sun, 10 Apr 2022 23:45:34 +0000 (19:45 -0400)]
Explain our use of mypyc in the FAQ (#3002)

I realized we don't have a FAQ entry about this, let's change that so
compiled: yes/no doesn't surprise as many people :)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2 years agoCorrectly handle fmt: skip comments without internal spaces (#2970)
Ryan Siu [Sat, 9 Apr 2022 20:52:45 +0000 (16:52 -0400)]
Correctly handle fmt: skip comments without internal spaces (#2970)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2 years agoRemove redundant parentheses around awaited coroutines/tasks (#2991)
Joe Young [Sat, 9 Apr 2022 20:49:40 +0000 (21:49 +0100)]
Remove redundant parentheses around awaited coroutines/tasks (#2991)

This is a tricky one as await is technically an expression and therefore
in certain situations requires brackets for operator precedence.
However, the vast majority of await usage is just await some_coroutine(...)
and similar in format to return statements. Therefore this PR removes
redundant parens around these await expressions.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agoBetter manage return annotation brackets (#2990)
Joe Young [Sat, 9 Apr 2022 14:36:05 +0000 (15:36 +0100)]
Better manage return annotation brackets (#2990)

Allows us to better control placement of return annotations by:

a) removing redundant parens
b) moves very long type annotations onto their own line

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2 years agoOutput python version and implementation as part of `--version` flag (#2997)
Joe Young [Wed, 6 Apr 2022 18:04:12 +0000 (19:04 +0100)]
Output python version and implementation as part of `--version` flag (#2997)

Example:

black, 22.1.1.dev56+g421383d.d20220405 (compiled: no)
Python (CPython) 3.9.12

Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
2 years agoTop PyPI Packages: Use 30-days data, 365 is no longer available (#2995)
Hugo van Kemenade [Wed, 6 Apr 2022 12:48:50 +0000 (15:48 +0300)]
Top PyPI Packages: Use 30-days data, 365 is no longer available (#2995)

2 years agoUpdate FAQ: Mention formatting of custom jupyter cell magic (#2982)
Jan-Hendrik Müller [Tue, 5 Apr 2022 01:24:16 +0000 (03:24 +0200)]
Update FAQ: Mention formatting of custom jupyter cell magic (#2982)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agoUpdate test_black.shhh_click test for click 8+ (#2993)
Richard Si [Tue, 5 Apr 2022 01:23:30 +0000 (21:23 -0400)]
Update test_black.shhh_click test for click 8+ (#2993)

The 8.0.x series renamed its "die on LANG=C" function and the 8.1.x
series straight up deleted it.

Unfortunately this makes this test type check cleanly hard, so we'll
just lint with click 8.1+ (the pre-commit hook configuration was changed
mostly to just evict any now unsupported mypy environments)

2 years agoRemove unnecessary parentheses from `with` statements (#2926)
Joe Young [Sun, 3 Apr 2022 03:27:33 +0000 (04:27 +0100)]
Remove unnecessary parentheses from `with` statements (#2926)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>