]> 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
3 years agoRemove docker CI from look at 'master' branch (#2209)
Cooper Lees [Sun, 9 May 2021 07:08:03 +0000 (00:08 -0700)]
Remove docker CI from look at 'master' branch (#2209)

3 years agoFix autodoc refs broken by refactor (#2207)
Richard Si [Sat, 8 May 2021 19:53:01 +0000 (15:53 -0400)]
Fix autodoc refs broken by refactor (#2207)

3 years agoReorganize docs v2 (GH-2174)
Richard Si [Sat, 8 May 2021 19:17:38 +0000 (15:17 -0400)]
Reorganize docs v2 (GH-2174)

I know I know, this is the second reorganization of the docs. I'm not
saying the first one was bad or anything... but.. actually wait nah,
*it was bad*.

Anyway, welcome to probably my biggest commit. The main thing with this
reorganization was to introduce nesting to the documentation! Having
all of the docs be part of the main TOC was becoming too much. There
wasn't much room to expand either. Finally, the old setup required
a documentation generation step which was just annoying.

The goals of this reorganization was to:

1. Significantly restructure the docs to be discoverable and
   understandable

2. Add room for further docs (like guides or contributing docs)

3. Get rid of the doc generation step (it was slow and frustrating)

4. Unblock other improvements and also just make contributing to the
   docs easier

Another important change with this is that we are no longer using GitHub
as a documentation host. While GitHub does support Markdown based docs
actually pretty well, the lack of any features outside of GitHub Flavoured
Markdown is quite limiting. ReadTheDocs is just much better suited for
documentation. You can use reST, MyST, CommonMark, and all of their
great features like toctrees and admonitions.

Related to this change, we're adopting MyST as our flavour of Markdown.
MyST introduces neat syntax extensions to Markdown that pretty much
gives us the best of both worlds. The ease of use and simplicity of MD
and the flexibility and expressiveness of reST. Also recommonmark is
deprecated now. This switch was possible now we don't use GH as a docs
host. MyST docs have to be built to really be usable / pretty, so the MD
docs are going to look pretty bad on GH, but that's fine now!

Another thing that should be noted is that the README has been stripped
of most content since it was confusing. Users would read the README and
then think some feature or bug was fixed already and is available in a
release when in reality, they weren't. They were reading effectively
the latest docs without knowing.

See also: https://github.com/psf/black/issues/1759

FYI: CommonMark is a rationalized version of Markdown syntax

--

Commit history before merge:

* Switch to MyST-Parser + doc config cleanup

  recommonmark is being deprecated in favour of MyST-Parser. This change
  is welcomed, especially since MyST-Parser has syntax extensions for the
  Commonmark standard. Effectively we get to use a language that's powerful
  and expressive like ReST, but get the simplicity of Markdown.

  The rest of this effort will be using some MyST features.

  This reorganization efforts aims to remove as much duplication as possible.
  The regeneration step once needed is gone, significantly simplifing our
  Sphinx documentation configuration.

* Tell pipenv we replaced recommonmark for MyST-Parser

  Also update `docs/requirements.txt`

* Delete all auto generated content
* Switch prettier for mdformat (plus a few plugins)

  **FYI: THIS WAS EFFECTIVELY REVERTED, SEE THIRD TO LAST COMMIT**

  prettier doesn't support MyST's syntax extensions which are going to be
  used in this reorganization effort so we have to switch formatter.

  Unfortanately mdformat's style is different from prettier's so time to
  reformat the whole repo too.

  We're excluding .github/ISSUE_TEMPLATE because I have no idea whether
  its changes are safe, so let's play it safe.

* Fix the heading levels in CHANGES.md + a link

  MyST-Parser / sphinx's linkcheck complains otherwise.

* Move reference docs into a docs/contributing dir

  They're for contributors of Black anyway. Also added a note in the
  summary document warning about the lack of attention the reference has
  been dealing with.

* Rewrite and setup the new landing page + main TOC

  - add some more detail about Black's beta status
  - add licensing info
  - add external links in the main TOC for GitHub, PyPI, and IRC
  - prepare main TOC for new structure

* Break out AUTHORS into its own file

  Not only was the AUTHORS list quite long, this makes it easy to include
  it in the Sphinx docs with just a simple symlink.

* Add license to docs via a simple include

  Yes the document is orphaned but it is linked to in the landing page
  (docs/index.rst).

* Add "The Black Code Style" section

  This mostly was a restructuring commit, there has been a few updates but
  not many. The main goal was to split "current style" and "planned
  changes to the style that haven't happened yet" to avoid confusion.

* Add "Getting Started" page

  This is basically a quick start + even more. This commit is certainly
  one of most creatively involved in this effort.

* Add "Usage and Configuration" section

  This commit was as much restructuring as new content. Instead of being
  in one giant file, usage and configuration documentation can expand
  without bloating a single file.

* Add "Integrations" section

Just a restructuring commit ...

* Add "Guides" section

  This is a promising area of documentation that could easily grow in the
  future, let's prepare for that!

* Add "Contributing" section

  This is also another area that I expect to see significant growth in.
  Contributors to Black could definitely do with some more specific docs
  that clears up certain parts of our slightly confusing project (it's
  only confusing because we're getting big and old!).

* Rewrite CONTRIBUTING.md to just point to RTD
* Rewrite README.md to delegate most info to RTD
* Address feedback + a lot of corrections and edits

  I know I said I wanted to do these after landing this but given there's
  going to be no time between this being merged and a release getting
  pushed, I want these changes to make it in.

  - drop the number flag for mdformat - to reduce diffs, see also:
    https://mdformat.readthedocs.io/en/stable/users/style.html#ordered-lists
  - the GH issue templates should be safe by mdformat, so get rid of the
    exclude
  - clarify our configuration position - i.e. stop claiming we don't have
    many options, instead say we want as little formatting knobs as
    possible
  - lots and lots of punctuation, spelling, and grammar corrections (thanks
    Jelle!)
  - use RTD as the source for the CHANGELOG too
  - visual style cleanups
  - add docs about our .gitignore behaviour
  - expand GHA Action docs
  - clarify we want the PR number in the CHANGELOG entry
  - claify Black's behaviour for with statements post Python 3.9
  - italicize a bunch of "Black"s

  Thank you goes to Jelle, Taneli (hukkinj1 on GH), Felix
  (felix-hilden on GH), and Wouter (wbolster on GH) for the feedback!

* Merge remote-tracking branch 'upstream/master' into reorganize-docs-v2

  merge conflicts suck, although these ones weren't too bad.

* Add changelog entry + fix merge conflict resolution error

  I consider this important enough to be worthy of a changelog entry :)

* Merge branch 'master' into reorganize-docs-v2

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* Actually let's continue using prettier

  Prettier works fine for all of the default MyST syntax so let's not
  rock the boat as much. Dropping the mdformat commit was merge-conflict
  filled so here's additional commit instead.

* Address Cooper's, Taneli's, and Jelle's feedback

  Lots of wording improvements by Cooper. Taneli suggested to disable the
  enabled by default MyST syntax not supported by Prettier and I agreed.
  And Jelle found one more spelling error!

* More minor fixes

3 years agoSpeed up tests even more (#2205)
Richard Si [Sat, 8 May 2021 09:34:25 +0000 (05:34 -0400)]
Speed up tests even more (#2205)

There's three optimizations in this commit:

1. Don't check if Black's output is stable or equivalant if no changes
   were made in the first place. It's not like passing the same code
   (for both source and actual) through black.assert_equivalent or
   black.assert_stable is useful. It's not a big deal for the smaller
   tests, but it eats a lot of time in tests/test_format.py since
   its test cases are big. This is also closer to how Black works IRL.

2. Use a smaller file for `test_root_logger_not_used_directly` since
   the logging it's checking happens during blib2to3's startup so the
   file doesn't really matter.

3. If we're checking a file is formatting (i.e. test_source_is_formatted)
   don't run Black over it again with `black.format_file_in_place`.
   `tests/test_format.py::TestSimpleFormat.check_file` is good enough.

3 years agoRefactor `src/black/__init__.py` into many files (#2206)
Łukasz Langa [Sat, 8 May 2021 09:29:47 +0000 (11:29 +0200)]
Refactor `src/black/__init__.py` into many files (#2206)

* Move string-related utility to functions to strings.py, const.py
* Move Leaf/Node-related functionality to nodes.py
* Move comment-related functions to comments.py
* Move caching to cache.py and Mode/TargetVersion/Feature to mode.py
* Move some leftover functions to nodes.py, comments.py, strings.py
* Add missing files to source list for test runs
* Move line-related functionality into lines.py, brackets into brackets.py
* Move transformers to trans.py
* Move file handling, output, parsing, concurrency, debug, and report
* Move two more functions to nodes.py
* Add CHANGES
* Add numeric.py
* Add linegen.py
* More docstrings
* Include new files in tests

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
3 years agoSpeed up test suite via distributed testing (#2196)
Richard Si [Fri, 7 May 2021 14:41:55 +0000 (10:41 -0400)]
Speed up test suite via distributed testing (#2196)

* Speed up test suite via distributed testing

Since we now run the test suite twice, one with Python 2 and another
without, full test runs are getting pretty slow. Let's try to
fix that with parallization.

Also use verbose mode on CI since more logs is usually better since
getting more is quite literally impossible.

The main issue we'll face with this is we'll hit
https://github.com/pytest-dev/pytest-xdist/issues/620 sometimes
(although pretty rarely). I suppose we can test this and see if how bad
this bug is for us, and revert if necessary down the line.

Also let's have some colours :tada:

3 years agoMark blackd tests with the `blackd` optional marker (#2204)
Łukasz Langa [Fri, 7 May 2021 14:33:36 +0000 (16:33 +0200)]
Mark blackd tests with the `blackd` optional marker (#2204)

This is a follow-up of #2203 that uses a pytest marker instead of a bunch of
`skipUnless`.  Similarly to the Python 2 tests, they are running by default and
will crash on an unsuspecting contributor with missing dependencies.  This is
by design, we WANT contributors to test everything.  Unless we actually don't
and then we can run:

  pytest --run-optional=no_blackd

Relatedly, bump required aiohttp to 3.6.0 at least to get rid of expected
failures on Python 3.8 (see 6b5eb7d4651c7333cc3f5df4bf7aa7a1f1ffb45b).

3 years agoUse optional tests for "no_python2" to simplify local testing (#2203)
Łukasz Langa [Fri, 7 May 2021 13:03:13 +0000 (15:03 +0200)]
Use optional tests for "no_python2" to simplify local testing (#2203)

3 years agoDo not use gitignore if explicitly passing excludes (#2170)
Kaleb Barrett [Fri, 7 May 2021 12:54:21 +0000 (07:54 -0500)]
Do not use gitignore if explicitly passing excludes (#2170)

Closes #2164.

Changes behavior of how .gitignore is handled. With this change, the rules in .gitignore are only used as a fallback if no exclusion rule is explicitly passed on the command line or in pyproject.toml. Previously they were used regardless if explicit exclusion rules were specified, preventing any overriding of .gitignore rules.

Those that depend only on .gitignore for their exclusion rules will not be affected. Those that use both .gitignore and exclude will find that exclude will act more like actually specifying exclude and not just another extra-excludes. If the previous behavior was desired, they should move their rules from exclude to extra-excludes.

3 years agoFix broken Action entrypoint (#2202)
Richard Si [Thu, 6 May 2021 19:21:13 +0000 (15:21 -0400)]
Fix broken Action entrypoint (#2202)

3 years agoSimplify GitHub Action entrypoint (#2119)
Shota Ray Imaki [Thu, 6 May 2021 02:25:43 +0000 (11:25 +0900)]
Simplify GitHub Action entrypoint (#2119)

This commit simplifies entrypoint.sh for GitHub Actions by removing
duplication of args and black_args (cf. #1909).

The reason why #1909 uses the input id black_args is to avoid an overlap
with args, but this naming seems redundant. So let me suggest option
and src, which are consistent with CLI. Backward compatibility is
guaranteed; Users can still use black_args as well.

Commit history pre-merge:
* Simplify GitHub Action entrypoint (#1909)
* Fix prettier
* Emit a warning message when `black_args` is used

  This deprecation should be visible in GitHub Action's UI now.

Co-authored-by: Shota Ray Imaki <shota.imaki.0801@gmail.com>
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
3 years agoEnable ` --experimental-string-processing` on most primer projects (#2184)
Cooper Lees [Wed, 5 May 2021 15:33:23 +0000 (08:33 -0700)]
Enable ` --experimental-string-processing` on most primer projects (#2184)

* Enable ` --experimental-string-processing` on all primer projects
- We want to make this default so need to test it more
- Fixed splat/star bug in extending black args for each project

* Disable sqlalchemy due to crash

3 years agoDisable pandas while we look into #2193 (#2195)
Cooper Lees [Tue, 4 May 2021 19:49:20 +0000 (12:49 -0700)]
Disable pandas while we look into #2193 (#2195)

3 years agoUpdate CHANGES.md for 21.5b0 release (#2192)
Cooper Lees [Tue, 4 May 2021 18:07:08 +0000 (11:07 -0700)]
Update CHANGES.md for 21.5b0 release (#2192)

* Update CHANGES.md for 21.5b0 release

* Make prettier happy

3 years agoUse pre-commit/action to simplify CI (#2191)
Hugo van Kemenade [Tue, 4 May 2021 11:41:04 +0000 (14:41 +0300)]
Use pre-commit/action to simplify CI (#2191)

3 years agocompatible isort config: mention profile first (#2180)
reka [Tue, 4 May 2021 08:48:59 +0000 (10:48 +0200)]
compatible isort config: mention profile first (#2180)

Change the order of possible ways to configure isort:
1. using the profile black
2. custom configuration

Formats section:
change the examples to use the profile black

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
3 years agoDrop Travis CI and migrate Coveralls (#2186)
Richard Si [Tue, 4 May 2021 08:47:59 +0000 (04:47 -0400)]
Drop Travis CI and migrate Coveralls (#2186)

Travis CI for Open Source is shutting down in a few weeks so the queue
for jobs is insane due to lower resources. I'm 99.99% sure we don't need
it as our Test, Lint, Docs, Upload / Package, Primer, and Fuzz workflows
are all on GitHub Actions. So even though we *can* migrate to the .com
version with its 1000 free Linux minutes(?), I don't think we need to.

more information here:
- https://blog.travis-ci.com/oss-announcement
- https://blog.travis-ci.com/2020-11-02-travis-ci-new-billing
- https://docs.travis-ci.com/user/migrate/open-source-repository-migration

This commit does the following:
- delete the Travis CI configuration
- add to the GHA test workflows so coverage continues to be recorded
  - tweaked coverage configuration so this wouldn't break
- remove any references to Travis CI in the docs (i.e. readme + sphinx
  docs)

Regarding the Travis CI to GitHub Actions Coveralls transition, the
official action doesn't support the coverage files produced by coverage.py
unfornately. Also no, I don't really know what I am doing so don't @ me
if this breaks :p (well you can, but don't expect me to be THAT useful).

The Coveralls setup has two downfalls AFAIK:
- Only Linux runs are used because AndreMiras/coveralls-python-action
  only supports Linux. Although this isn't a big issue since the Travis
  Coveralls configuration only used Linux data too.
- Pull requests from an internal branch (i.e. one on psf/black) will be
  marked as a push coverage build by Coveralls since our anti-duplicate-
  workflows system runs under the push even for such cases.

3 years agoadd test configurations that don't contain python2 optional install (#2190)
KotlinIsland [Tue, 4 May 2021 08:47:22 +0000 (18:47 +1000)]
add test configurations that don't contain python2 optional install (#2190)

add test for negative scenario: formatting python2 code
tag python2 only tests

Co-authored-by: KotlinIsland <kotlinisland@users.noreply.github.com>
3 years agoDetect `'@' dotted_name '(' ')' NEWLINE` as a simple decorator (#2182)
Richard Si [Tue, 4 May 2021 08:46:46 +0000 (04:46 -0400)]
Detect `'@' dotted_name '(' ')' NEWLINE` as a simple decorator (#2182)

Previously the RELAXED_DECORATOR detection would be falsely True on that
example. The problem was that an argument-less parentheses pair didn't
pass the `is_simple_decorator_trailer` check even it should. OTOH a
parentheses pair containing an argument or more passed as expected.

3 years agoprimer: Add `--no-diff` option (#2187)
Cooper Lees [Tue, 4 May 2021 08:44:40 +0000 (01:44 -0700)]
primer: Add `--no-diff` option (#2187)

- Allow runs with no code diff output
- This is handy for reducing output to see which file is erroring

Test:
- Edit config for 'channels' to expect no changes and run with `--no-diff` and see no diff output

3 years agoprimer: Renable pandas (#2185)
Cooper Lees [Mon, 3 May 2021 21:58:17 +0000 (14:58 -0700)]
primer: Renable pandas (#2185)

- It no longer crashes black so we should test on it's code
- Update django reason to name the file causing error
  - Seems it has a syntax error on purpose

3 years agoSet `is_pyi` if `stdin_filename` ends with `.pyi` (#2169)
Bryan Forbes [Sun, 2 May 2021 12:48:54 +0000 (07:48 -0500)]
Set `is_pyi` if `stdin_filename` ends with `.pyi` (#2169)

Fixes #2167

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
3 years agoTox has been formatted with Black 21.4b0 (#2175)
Hugo van Kemenade [Sat, 1 May 2021 19:17:20 +0000 (22:17 +0300)]
Tox has been formatted with Black 21.4b0 (#2175)

3 years agoAdd ability to pass posargs to pytest run in tox.ini (#2173)
Kaleb Barrett [Sat, 1 May 2021 18:47:59 +0000 (13:47 -0500)]
Add ability to pass posargs to pytest run in tox.ini (#2173)

3 years agoElaborate on what AST changes Black might perform
Łukasz Langa [Wed, 28 Apr 2021 14:48:04 +0000 (16:48 +0200)]
Elaborate on what AST changes Black might perform

3 years agoUpdate CHANGELOG for 21.4b2 release (#2162)
Cooper Lees [Wed, 28 Apr 2021 14:21:56 +0000 (07:21 -0700)]
Update CHANGELOG for 21.4b2 release (#2162)

3 years agoRemove useless shebangs in non-executable files (#2161)
Miro Hrončok [Wed, 28 Apr 2021 14:07:15 +0000 (16:07 +0200)]
Remove useless shebangs in non-executable files (#2161)

Such shebangs are only ever used if the file is executed directly, i.e.:

    $ /usr/lib/python3.9/site-packages/black_primer/cli.py

But that doesn't work:

    $ /usr/lib/python3.9/site-packages/black_primer/cli.py
    bash: /usr/lib/python3.9/site-packages/black_primer/cli.py: Permission denied

The lib file even has: "lib is a library, funnily enough"

3 years agoAdd automatic version tagging to Docker CI Pushes (#2132)
Cooper Lees [Wed, 28 Apr 2021 03:10:44 +0000 (20:10 -0700)]
Add automatic version tagging to Docker CI Pushes (#2132)

* Add automatic version tagging to Docker Uploads
- If the git comment has a tag, set that on the docker images pushed
- If we don't have a tag, we just set `latest_non_release`

* Add trigger on release creation too

* Make prettier happy omn docker.yml

3 years agoIgnore inaccessible user config (#2158)
Jelle Zijlstra [Tue, 27 Apr 2021 21:16:35 +0000 (14:16 -0700)]
Ignore inaccessible user config (#2158)

Fixes #2157

3 years agoUpdate discussion of AST safety check in README (#2159)
Jelle Zijlstra [Tue, 27 Apr 2021 21:00:17 +0000 (14:00 -0700)]
Update discussion of AST safety check in README (#2159)

3 years agoInstall primer.json (used by black-primer by default) with black (#2154)
Miro Hrončok [Tue, 27 Apr 2021 15:58:39 +0000 (17:58 +0200)]
Install primer.json (used by black-primer by default) with black (#2154)

Fixes https://github.com/psf/black/issues/2153

3 years agoAdd pyanalyze and typeshed to black-primer (#2152)
Jelle Zijlstra [Tue, 27 Apr 2021 15:33:51 +0000 (08:33 -0700)]
Add pyanalyze and typeshed to black-primer (#2152)

pyanalyze is one of my projects and it uses `--experimental-string-processing`.

typeshed has a lot of stub files.

3 years agoUpdate CHANGELOG for 21.4b1 release (#2151)
Cooper Lees [Tue, 27 Apr 2021 14:40:08 +0000 (07:40 -0700)]
Update CHANGELOG for 21.4b1 release (#2151)

* Update CHANGELOG for 21.4b1 release

* Add pathspec minimum bump + update primer not to expect changes for virtualenv

3 years agoMaintainers += Richard Si (aka ichard26) (#2149)
Richard Si [Mon, 26 Apr 2021 20:59:45 +0000 (16:59 -0400)]
Maintainers += Richard Si (aka ichard26) (#2149)

3 years agoStop stripping parens in even more illegal spots (#2148)
Richard Si [Mon, 26 Apr 2021 20:26:43 +0000 (16:26 -0400)]
Stop stripping parens in even more illegal spots (#2148)

We're only fixing them so fuzzers don't yell at us when we break "valid"
code. I mean "valid" because some of the examples aren't even accepted by
Python.

3 years agoBump pathspec to >= 0.8.1 to solve invalid .gitignore exclusion handling (#2084)
Łukasz Langa [Mon, 26 Apr 2021 19:22:25 +0000 (21:22 +0200)]
Bump pathspec to >= 0.8.1 to solve invalid .gitignore exclusion handling (#2084)

Also made the Click requirement in Pipfile consistent with setup.py and bumped mypy.

3 years agoAdd more tests for fancy whitespace (#2147)
Łukasz Langa [Mon, 26 Apr 2021 18:24:06 +0000 (20:24 +0200)]
Add more tests for fancy whitespace (#2147)

3 years agoFix crash on docstrings ending with "\ " (#2142)
Jelle Zijlstra [Mon, 26 Apr 2021 17:42:16 +0000 (10:42 -0700)]
Fix crash on docstrings ending with "\ " (#2142)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
3 years agoSymlink docs/change_log.md to CHANGES.md, don't copy (#2146)
Richard Si [Mon, 26 Apr 2021 17:26:03 +0000 (13:26 -0400)]
Symlink docs/change_log.md to CHANGES.md, don't copy (#2146)

Super duper janky stopgap fix until I get my documentation reorganization
work done and merged

3 years agoDon't strip parens in assert / return with assign expr (#2143)
Richard Si [Mon, 26 Apr 2021 15:28:42 +0000 (11:28 -0400)]
Don't strip parens in assert / return with assign expr (#2143)

Black would previously strip the parenthesis away from statements like this these ones:

    assert (spam := 12 + 1)
    return (cheese := 1 - 12)

Which happens to be invalid code. Now before making the parenthesis invisible, Black
checks if the assignment expression's parent is an assert stamtment, aborting if True.

Raise, yield, and await are already handled fine.

I added a bunch of test cases from the PEP defining asssignment expressions (PEP 572).

3 years agofix magic comma and experimental string cache flags (#2131)
Jelle Zijlstra [Mon, 26 Apr 2021 05:46:48 +0000 (22:46 -0700)]
fix magic comma and experimental string cache flags (#2131)

* fix magic comma and experimental string cache flags

* more changelog

* Update CHANGES.md

Co-authored-by: Cooper Lees <me@cooperlees.com>
* fix tests

Co-authored-by: Cooper Lees <me@cooperlees.com>
3 years agoRemove Lowercase Hex (PR #1692) from CHANGES.md (#2133)
Cooper Lees [Mon, 26 Apr 2021 03:48:04 +0000 (20:48 -0700)]
Remove Lowercase Hex (PR #1692) from CHANGES.md (#2133)

- It was reverted to not cause so much diff churn on millions of lines of code
- Fix primer config for projects that should now pass

3 years agoUpdate CHANGES.md for release (#2129)
Cooper Lees [Sun, 25 Apr 2021 22:12:27 +0000 (15:12 -0700)]
Update CHANGES.md for release (#2129)

3 years agoIssue 1629 has been closed, let's celebrate! (#2127)
Richard Si [Sun, 25 Apr 2021 21:52:23 +0000 (17:52 -0400)]
Issue 1629 has been closed, let's celebrate! (#2127)

3 years agoDocker CI: Add missed Checkout step (#2128)
Cooper Lees [Sun, 25 Apr 2021 21:51:13 +0000 (14:51 -0700)]
Docker CI: Add missed Checkout step (#2128)

- Reading my error others hit it by forgetting this Checkoutstep too so trying the fix
  - e.g. https://github.com/docker/build-push-action/issues/179
- Makes sense it's needed

3 years agoAdd Docker Github Action (#2086)
Cooper Lees [Sun, 25 Apr 2021 18:27:35 +0000 (11:27 -0700)]
Add Docker Github Action (#2086)

* Add Docker Github Action
- Build and upload arm64 + amd64 black images on push to master

This will need a `DOCKERHUB_USERNAME` and `DOCKERHUB_TOKEN` secrets set by someone with access.

* Change tag to push to pyfound/black repository. Thanks @ewdurbin

3 years agoWork around stability errors due to optional trailing commas (#2126)
Łukasz Langa [Sun, 25 Apr 2021 18:15:54 +0000 (20:15 +0200)]
Work around stability errors due to optional trailing commas (#2126)

Optional trailing commas put by Black become magic trailing commas on another
pass of the tool.  Since they are influencing formatting around optional
parentheses, on rare occasions the tool changes its mind in terms of putting
parentheses or not.

Ideally this would never be the case but sadly the decision to put optional
parentheses or not (which looks at pre-existing "magic" trailing commas) is
happening around the same time as the decision to put an optional trailing
comma.  Untangling the two proved to be impractically difficult.

This shameful workaround uses the fact that the formatting instability
introduced by magic trailing commas is deterministic: if the optional trailing
comma becoming a pre-existing "magic" trailing comma changes formatting, the
second pass becomes stable since there is no variable factor anymore on pass 3,
4, and so on.

For most files, this will introduce no performance penalty since `--safe` is
already re-formatting everything twice to ensure formatting stability.  We're
using this result and if all's good, the behavior is equivalent.  If there is
a difference, we treat the second result as the binding one, and check its
sanity again.

3 years agoFix primer config
Łukasz Langa [Sun, 25 Apr 2021 17:44:06 +0000 (19:44 +0200)]
Fix primer config

3 years agoRe-add .venv to .gitignore
Łukasz Langa [Sun, 25 Apr 2021 17:42:02 +0000 (19:42 +0200)]
Re-add .venv to .gitignore

3 years agoRevert "Use lowercase hex numbers fixes #1692 (#1775)"
Łukasz Langa [Sun, 25 Apr 2021 17:04:15 +0000 (19:04 +0200)]
Revert "Use lowercase hex numbers fixes #1692 (#1775)"

This reverts commit 7d032fa848c8910007a0a41c1ba61d70d2846f48.

3 years agoDocument experimental string processing and docstring indentation (#2106)
Felix Hildén [Thu, 22 Apr 2021 17:37:27 +0000 (20:37 +0300)]
Document experimental string processing and docstring indentation (#2106)

3 years agoHandle Docstrings as bytes + strip all whitespace (#2037)
CiderMan [Thu, 22 Apr 2021 15:40:51 +0000 (16:40 +0100)]
Handle Docstrings as bytes + strip all whitespace (#2037)

(fixes #1844, fixes #1923, fixes #1851, fixes #2002, fixes #2103)

3 years agoMake black remove leading and trailing spaces from one-line docstrings (#1740)
Mark Bell [Thu, 22 Apr 2021 15:23:41 +0000 (16:23 +0100)]
Make black remove leading and trailing spaces from one-line docstrings (#1740)

Fixes #1738. Fixes #1812.

Previously, Black removed leading and trailing spaces in multiline docstrings but failed to remove them from one-line docstrings.

3 years agoInstructions on documenting code style modifications (#2109)
Felix Hildén [Sun, 18 Apr 2021 21:18:39 +0000 (00:18 +0300)]
Instructions on documenting code style modifications (#2109)

3 years agoFix small comment typo (#2112)
Laurent Tréguier [Fri, 16 Apr 2021 17:41:19 +0000 (19:41 +0200)]
Fix small comment typo (#2112)

We probably don't need to fall back on "polling" when setting up an asyncio loop

3 years agoAdd missing instructions to make test passed (#2100)
Pierre Verkest [Mon, 12 Apr 2021 13:18:11 +0000 (15:18 +0200)]
Add missing instructions to make test passed (#2100)

3 years agoRemove NBSP at the beginning of comments (#2092)
Pierre Sassoulas [Sun, 11 Apr 2021 21:41:22 +0000 (23:41 +0200)]
Remove NBSP at the beginning of comments (#2092)

Closes #2091

3 years agoAdded not formatting files in gitignore (psf#1682) (#1734)
Simon [Sun, 11 Apr 2021 21:00:03 +0000 (07:00 +1000)]
Added not formatting files in gitignore (psf#1682) (#1734)

3 years agofix typing issue around lru_cache arguments (#2098)
Jelle Zijlstra [Sun, 11 Apr 2021 14:49:42 +0000 (07:49 -0700)]
fix typing issue around lru_cache arguments (#2098)

This was found by python/mypy#10308

3 years agoExclude venv directory by default (#1683)
johnthagen [Sat, 10 Apr 2021 12:07:34 +0000 (08:07 -0400)]
Exclude venv directory by default (#1683)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
3 years agoFix error from upcoming typeshed change (#2096)
Jelle Zijlstra [Thu, 8 Apr 2021 17:25:37 +0000 (10:25 -0700)]
Fix error from upcoming typeshed change (#2096)

See python/typeshed#5190

3 years agoAdd `black` Dockerfile (#1916)
Cooper Lees [Thu, 8 Apr 2021 04:13:11 +0000 (21:13 -0700)]
Add `black` Dockerfile (#1916)

* Add `black` Dockerfile
- Build a `black` container based on python3-slim
- Test: `docker build --network-host --tag black .`
```console
cooper-mbp1:black cooper$ docker image ls
REPOSITORY                                         TAG            IMAGE ID       CREATED              SIZE
black                                              latest         0c7636402ac2   4 seconds ago        332MB
```

Addresses part of #1914

* Build with colorama + d extra installs - Adds ~9mb

* Combine all build commands in 1 run
- Combine the commands all into 1 RUN to down the size
- Get to 65.98 MB image size now: https://hub.docker.com/repository/docker/cooperlees/black/tags?page=1&ordering=last_updated

* Add rm -r of /var/lib/apt/lists/* + save 10mb down to 55mb

3 years agoBump urllib3 from 1.26.3 to 1.26.4 (#2090)
dependabot[bot] [Tue, 6 Apr 2021 18:07:57 +0000 (11:07 -0700)]
Bump urllib3 from 1.26.3 to 1.26.4 (#2090)

Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.26.3 to 1.26.4.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](https://github.com/urllib3/urllib3/compare/1.26.3...1.26.4)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years agoGet rid of redundant spaces in docs (#2085)
Jakub Warczarek [Sun, 4 Apr 2021 14:21:33 +0000 (16:21 +0200)]
Get rid of redundant spaces in docs (#2085)

Thanks!

3 years agoRun lint in latest python + update precommit (#2081)
Cooper Lees [Thu, 1 Apr 2021 23:15:50 +0000 (16:15 -0700)]
Run lint in latest python + update precommit (#2081)

- Lets move to latest and greatest of lints

3 years agoPush contributors to use Next PR Number (#2080)
Richard Si [Thu, 1 Apr 2021 21:24:18 +0000 (17:24 -0400)]
Push contributors to use Next PR Number (#2080)

This is a tool of my own making. Right now our requirement to have the
PR number in the changelog entry is pretty painful / annoying since
the contributor either has to guess or add the # retroactively after
the PR creation. This tool should make it way less painful by making
it simple to get your PR number beforehand.

3 years agoAdd CONTRBUTING info about CHANGES.md requirement (#2073)
Cooper Lees [Thu, 1 Apr 2021 16:54:45 +0000 (09:54 -0700)]
Add CONTRBUTING info about CHANGES.md requirement (#2073)

Instruct contributors to add the change line to help save maintainer / releaser time

3 years agoAdd a GitHub Action to build + Upload black to PyPI (#1848)
Cooper Lees [Thu, 1 Apr 2021 16:41:55 +0000 (09:41 -0700)]
Add a GitHub Action to build + Upload black to PyPI (#1848)

* Add a GitHub Action to build + Upload black to PyPI
- Build a wheel + sdist
- Upload via twine using token stored in GitHub secrets

3 years agoSupport for top-level user configuration (#1899)
Harish Rajagopal [Thu, 1 Apr 2021 16:39:18 +0000 (18:39 +0200)]
Support for top-level user configuration (#1899)

* Added support for top-level user configuration

At the user level, a TOML config can be specified in the following locations:
* Windows: ~\.black
* Unix-like: $XDG_CONFIG_HOME/black (~/.config/black fallback)

Instead of changing env vars for the entire black-primer process, they
are now changed only for the black subprocess, using a tmpdir.

3 years agodon't require typed-ast
KotlinIsland [Tue, 16 Mar 2021 09:31:18 +0000 (19:31 +1000)]
don't require typed-ast

3 years agoBump pygments from 2.6.1 to 2.7.4 in /docs (#2076)
dependabot[bot] [Tue, 30 Mar 2021 01:59:57 +0000 (18:59 -0700)]
Bump pygments from 2.6.1 to 2.7.4 in /docs (#2076)

Bumps [pygments](https://github.com/pygments/pygments) from 2.6.1 to 2.7.4.
- [Release notes](https://github.com/pygments/pygments/releases)
- [Changelog](https://github.com/pygments/pygments/blob/master/CHANGES)
- [Commits](https://github.com/pygments/pygments/compare/2.6.1...2.7.4)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years agoGREP for PR reference accepts references that are split over a line (#2072)
Mark Bell [Sun, 28 Mar 2021 23:01:37 +0000 (00:01 +0100)]
GREP for PR reference accepts references that are split over a line (#2072)

Fixes #2070

3 years agoAdd `--skip-magic-trailing-comma` to CHANGES.md (#2064)
Shantanu [Fri, 26 Mar 2021 14:21:18 +0000 (07:21 -0700)]
Add `--skip-magic-trailing-comma` to CHANGES.md (#2064)

3 years agoAdd entry for `--extend-exclude` in the right place (#2061)
Richard Si [Wed, 24 Mar 2021 23:38:07 +0000 (19:38 -0400)]
Add entry for `--extend-exclude` in the right place (#2061)

The PR author added the changelog entry for their `extend-exclude` addition
in `docs/change_log.md` which is understandable but incorrect as it will be
overwritten since it's autogenerated from the readme.

3 years agoAdd a GitHub CHANGELOG/News Check (#2057)
Cooper Lees [Sun, 21 Mar 2021 20:05:24 +0000 (13:05 -0700)]
Add a GitHub CHANGELOG/News Check (#2057)

- Run grep to see commit has a line mentioning it to CHANGES.md
- Also add a label to disable this being required for PRs that don't need a change entry

3 years agoFix indentation in docs/editor_integration.md (#2056)
Richard Si [Sat, 20 Mar 2021 19:15:55 +0000 (15:15 -0400)]
Fix indentation in docs/editor_integration.md (#2056)

Numbered list entries' bodies need to be indented or else the list won't
render correctly.

3 years agoRecommend B950 + 88 char limit instead of 80 (#2050)
Jairo Llopis [Thu, 18 Mar 2021 15:14:15 +0000 (15:14 +0000)]
Recommend B950 + 88 char limit instead of 80 (#2050)

[The section about line length][1] was contradictory.

On one side, it said:

> Black will try to respect that [line length limit]. However, sometimes it won't be able to without breaking other rules. In those rare cases, auto-formatted code will exceed your allotted limit.

So black doesn't guarantee that your code is formatted at 88 chars, even when configured with `--line-length=88` (default). Black uses this limit as a "hint" more than a "rule".

OTOH, it also said:

> If you're using Flake8, you can bump max-line-length to 88 and forget about it. Alternatively, use Bugbear's B950 warning instead of E501 and keep the max line length at 80 which you are probably already using.

But that's not true. You can't "forget about it" because Black sometimes won't respect the limit. Both E501 at 88 and B950 at 80 behave the same: linter error at 89+ length. So, if Black happens to decide that a line of code is better at 90 characters that some other fancy style, you land on a unlucky situation where both tools will fight.

So, AFAICS, the best way to align flake8 and black is to:

1. Use flake8-bugbear
2. Enable B950
3. Disable E501
4. Set `max-line-length = 88`

This way, we also tell flake8 that 88 limit is a "hint" and not a "rule". The real rule will be 88 + 10%. If black decides that a line fits better in 97 characters than in 88 + some formatting, _that_ probably means your code has a real problem.

To avoid further confusion, I change the official recommendation here.

[1]: https://github.com/PyCQA/flake8-bugbear/tree/e82bb8d8b855adbf1f6f9757fb1527e93039e0d9#opinionated-warnings

3 years agoUse vim autoload script (#1157)
Konstantin Alekseev [Mon, 8 Mar 2021 00:13:25 +0000 (03:13 +0300)]
Use vim autoload script (#1157)

3 years agoAdd missing changelog entry for fmt: skip (#2025)
Richard Si [Sat, 6 Mar 2021 20:02:25 +0000 (15:02 -0500)]
Add missing changelog entry for fmt: skip (#2025)

3 years agoAdd ALE (#1753)
John Meow [Sat, 6 Mar 2021 04:22:19 +0000 (07:22 +0300)]
Add ALE (#1753)

3 years agoRemove unused import statements using Pycln. (#2021)
Hadi Alqattan [Fri, 5 Mar 2021 19:58:00 +0000 (22:58 +0300)]
Remove unused import statements using Pycln. (#2021)

* remove unused imports using Pycln.

* reverse comma style.

3 years agoBump aiohttp from 3.7.3 to 3.7.4 (#2009)
dependabot[bot] [Fri, 5 Mar 2021 18:43:54 +0000 (10:43 -0800)]
Bump aiohttp from 3.7.3 to 3.7.4 (#2009)

Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.7.3 to 3.7.4.
- [Release notes](https://github.com/aio-libs/aiohttp/releases)
- [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst)
- [Commits](https://github.com/aio-libs/aiohttp/compare/v3.7.3...v3.7.4)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years agoBlack requires Python 3.6.2+ (#1668)
Hugo van Kemenade [Thu, 4 Mar 2021 13:59:31 +0000 (15:59 +0200)]
Black requires Python 3.6.2+ (#1668)

3 years agoAdd formatters-python for atom to editor_integration (#1834)
Utkarsh Gupta [Thu, 4 Mar 2021 00:46:27 +0000 (06:16 +0530)]
Add formatters-python for atom to editor_integration (#1834)

3 years agoTurn test_regex into a click callback (#2016)
Joshua Cannon [Wed, 3 Mar 2021 01:21:50 +0000 (19:21 -0600)]
Turn test_regex into a click callback (#2016)

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
3 years agoAdds --stdin-filename back to changelog (#2017)
Austin Pray [Tue, 2 Mar 2021 00:35:57 +0000 (18:35 -0600)]
Adds --stdin-filename back to changelog (#2017)

* Adds --stdin-filename back to changelog

Looks like this went missing https://github.com/psf/black/commit/dea81b7ad5cfa04c3572771c34af823449d0a8f3#diff-729efdd61772b108539268bdbfd7472521bdc05a7cae6113f62ed2649a3ad9c7

* Update CHANGES.md

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* Update CHANGES.md

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
3 years agoAdd --extend-exclude parameter (#2005)
Joshua Cannon [Mon, 1 Mar 2021 22:07:36 +0000 (16:07 -0600)]
Add --extend-exclude parameter (#2005)

Look ma! I contribute to open source!

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
3 years agoStrip redundant parentheses from assignment exprs (#1906)
Rishav Kundu [Sun, 28 Feb 2021 01:20:23 +0000 (06:50 +0530)]
Strip redundant parentheses from assignment exprs (#1906)

Fixes #1656

3 years agoWrap arithmetic and binary arithmetic expressions in invisible parentheses (#2001)
tpilewicz [Wed, 24 Feb 2021 11:56:56 +0000 (12:56 +0100)]
Wrap arithmetic and binary arithmetic expressions in invisible parentheses (#2001)

3 years agoFuzzer testing: less strict special-case regex match passthrough for multi-line EOF...
James Addison [Mon, 22 Feb 2021 15:49:38 +0000 (15:49 +0000)]
Fuzzer testing: less strict special-case regex match passthrough for multi-line EOF exceptions (#1998)

3 years agoFixup: update function name in docs to match source (#1997)
James Addison [Mon, 22 Feb 2021 15:46:38 +0000 (15:46 +0000)]
Fixup: update function name in docs to match source (#1997)

3 years agoFix for enum changes in 3.10 (#1999)
James [Mon, 22 Feb 2021 15:42:05 +0000 (15:42 +0000)]
Fix for enum changes in 3.10 (#1999)

3 years agoIndicate that a final newline was added in --diff (#1897) (#1897)
Paul "TBBle" Hampson [Mon, 22 Feb 2021 06:43:23 +0000 (17:43 +1100)]
Indicate that a final newline was added in --diff (#1897) (#1897)

Fixes: #1662
Work-around for https://bugs.python.org/issue2142

The test has to slightly mess with its input data, because the utility
functions default to ensuring the test data has a final newline, which
defeats the point of the test.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
3 years agoMinimize changes: more closely resemble original conditional logic
James Addison [Wed, 10 Feb 2021 12:33:50 +0000 (12:33 +0000)]
Minimize changes: more closely resemble original conditional logic

3 years agoReadability: reduce boolean nesting
James Addison [Tue, 9 Feb 2021 21:13:57 +0000 (21:13 +0000)]
Readability: reduce boolean nesting

3 years agoCleanup: remove unused / redundant variables from conditionals
James Addison [Thu, 4 Feb 2021 18:07:43 +0000 (18:07 +0000)]
Cleanup: remove unused / redundant variables from conditionals

3 years agoSimplification: only yield empty omit list when magic trailing comma is present
James Addison [Thu, 4 Feb 2021 17:48:38 +0000 (17:48 +0000)]
Simplification: only yield empty omit list when magic trailing comma is present

3 years agoSimplification: only use special-case token retrieval logic when magic trailing comma...
James Addison [Thu, 4 Feb 2021 17:45:45 +0000 (17:45 +0000)]
Simplification: only use special-case token retrieval logic when magic trailing comma is present

3 years agoClarity: special case: avoid using variables that have the same names as methods
James Addison [Thu, 4 Feb 2021 17:40:42 +0000 (17:40 +0000)]
Clarity: special case: avoid using variables that have the same names as methods

3 years agoConsistency: use variable names that correspond to the methods they invoke
James Addison [Thu, 4 Feb 2021 17:38:55 +0000 (17:38 +0000)]
Consistency: use variable names that correspond to the methods they invoke