]> 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
4 years agoMake 'python -m black' work (#1460)
Richard Si [Wed, 27 May 2020 02:42:07 +0000 (22:42 -0400)]
Make 'python -m black' work (#1460)

4 years agoUpdate CONTRIBUTION.md with pre-commit + black-primer instructions (#1459)
Cooper Lees [Sun, 24 May 2020 19:02:52 +0000 (12:02 -0700)]
Update CONTRIBUTION.md with pre-commit + black-primer instructions (#1459)

* Update CONTRIBUTION with pre-commit + black-primer instructions
- Inform people how to run primer and alter it's config
- Link to main documentation

* Apply suggestions from code review

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
4 years agoRefactor docs / Maintenance of docs (#1456)
Richard Si [Sun, 24 May 2020 16:37:46 +0000 (12:37 -0400)]
Refactor docs / Maintenance of docs (#1456)

* Split code style and components documentation

Splits 'the_black_code_style', 'pragmatism', 'blackd',and 'black_primer'
into their own files. The exception being 'the_black_code_style' and
'pragmatism'. They have been merged into one 'the_black_code_style_and_pragmatism'
file.

These changes are being made because the README is becoming very long. And
a README isn't great if it dissuades its reader because of its length.

* Update the doc generation logic and configuration

With the moving of several sections in the README and the renaming of a
few files, 'conf.py' needs to be able to support custom sections.

This commit introduces DocSection which can be used to specify custom
sections of documentation. The information stored in DocSection will be
used by the process_sections function to read, process, and write the section
to CURRENT_DIR.

A large change has been made to the how the docs are prepared to be built.
Instead of just generating the files needed by reading the README, this
has a full chain of operations so custom sections are supported. First,
it reads the README and spits out a list of DocSection objects representing
the sections to be generated by process_sections. This is done since most
of the docs still live in README. Then along with the defined custom_sections
, the process_sections will be begin to process the DocSection objects.
It reads the information it needs to generate the section. Then fetches
the section's contents, calls processors required by the section to process
the section's contents, and finally writes the section to CURRENT_DIR.

This large change is so processing of the documentation can be done just
for the versions hosted on ReadTheDocs.org. An example processor using this
feature is a 'replace_links' processor. It will replace documentation
links that point to the docs hosted on GitHub with links that point to the
version hosted on ReadTheDocs.org. (I won't be coding that ATM)

This also means that files will be overwritten or created once the docs
have been built. It is annoying, since you have to 'git reset --hard'
and 'git clean -f -d' after each build, but there's nothing better. The old
system had the same side effects, so yeah :(

* Update filenames and delete unnecessary files

Update the filenames since 'the_black_code_style' and 'pragmatism' were
merged and 'contributing' was deleted in favor of 'contributing_to_black'.

All symlinks were deleted since their home (_build/generated) is no longer
used.

* Fix broken links and a few redirections

* Merge master into refactor_docs (manually done)

* Add my and most of @hugovk suggestions

Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
* Add logging and improve configurability

Just some cleaning up up of the DocSection dataclass and added logging
support so you know what's going on.

* Rename a section and please the grammar gods of Black

Thanks @hugovk for the suggestion!

* Fix Markdown comments

* Add myself as an author :P

Seems like the right time.

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
4 years agoScrollable sidebar (#1457)
Richard Si [Sat, 23 May 2020 18:56:50 +0000 (14:56 -0400)]
Scrollable sidebar (#1457)

* Make the sidebar navigation scrollable

This is necessary since we have so many documentation sections that even
on a desktop screen, the navigation can sometimes be clipped. The only
annoyance is that on Firefox, the scrollbar can't be hidden :(

* allow the docs to build

4 years agoCapture CalledProcessError for any postitive returncode (#1450)
Cooper Lees [Fri, 22 May 2020 19:16:31 +0000 (12:16 -0700)]
Capture CalledProcessError for any postitive returncode (#1450)

- Leave logic to still allow for formatting changes to be ignored
- Now just capture the output of any other error that has a > 1 returncode
- Raise on anything else

Test: Add unit test to exercise this new logic

4 years agoAdd Primer badge to README.md (#1454)
Cooper Lees [Fri, 22 May 2020 19:15:41 +0000 (12:15 -0700)]
Add Primer badge to README.md (#1454)

4 years agoMove primer to own workflow (#1451)
Hugo van Kemenade [Fri, 22 May 2020 18:38:37 +0000 (21:38 +0300)]
Move primer to own workflow (#1451)

4 years agoUpdate README.md (#1453)
Gustavo Camargo [Fri, 22 May 2020 18:37:34 +0000 (13:37 -0500)]
Update README.md (#1453)

4 years agoEnable primer on CI Runs + add all README listed black projects into primer.json...
Cooper Lees [Fri, 22 May 2020 04:57:58 +0000 (21:57 -0700)]
Enable primer on CI Runs + add all README listed black projects into primer.json (#1440)

* Add all listed by projects into primer.json + Enable on CI Runs
- Change workers default to 2 as black uses system CPU count
- Increase timeout to 5 mins for subprocess black runs
- Takes about 120s for 13 (3 disabled) projects on my 2018 Macbook Pro
  - I was not removing directories tho ...

Will open an issue to investigate the failing projects and make this run cleaner.
- Once we get more stable we can expect more repos to be black formatted

Run it:
- `black-primer -k -w /tmp/primer_large_test --debug --rebase`
```
[2020-05-20 21:44:01,273] DEBUG: Starting /Users/cooper/venvs/b/bin/black-primer (cli.py:125)
[2020-05-20 21:44:01,273] DEBUG: Using selector: KqueueSelector (selector_events.py:53)
[2020-05-20 21:44:01,274] INFO: 16 projects to run Black over (lib.py:276)
[2020-05-20 21:44:01,274] DEBUG: Using 2 parallel workers to run Black (lib.py:281)
[2020-05-20 21:44:01,274] DEBUG: worker 0 workng on aioexabgp (lib.py:215)
[2020-05-20 21:44:01,276] DEBUG: worker 1 workng on attrs (lib.py:215)
[2020-05-20 21:44:02,443] INFO: Finished aioexabgp (lib.py:249)
[2020-05-20 21:44:02,443] DEBUG: worker 0 workng on bandersnatch (lib.py:215)
[2020-05-20 21:44:04,409] INFO: Finished bandersnatch (lib.py:249)
[2020-05-20 21:44:04,409] DEBUG: worker 0 workng on channels (lib.py:215)
[2020-05-20 21:44:04,702] INFO: Finished attrs (lib.py:249)
[2020-05-20 21:44:04,702] DEBUG: worker 1 workng on django (lib.py:215)
[2020-05-20 21:44:04,702] INFO: Skipping django as it's disabled via config (lib.py:222)
[2020-05-20 21:44:04,702] DEBUG: worker 1 workng on flake8-bugbear (lib.py:215)
[2020-05-20 21:44:05,813] INFO: Finished channels (lib.py:249)
[2020-05-20 21:44:05,813] DEBUG: worker 0 workng on hypothesis (lib.py:215)
[2020-05-20 21:44:06,071] INFO: Finished flake8-bugbear (lib.py:249)
[2020-05-20 21:44:06,071] DEBUG: worker 1 workng on pandas (lib.py:215)
[2020-05-20 21:44:06,071] INFO: Skipping pandas as it's disabled via config (lib.py:222)
[2020-05-20 21:44:06,071] DEBUG: worker 1 workng on poetry (lib.py:215)
[2020-05-20 21:44:16,207] INFO: Finished hypothesis (lib.py:249)
[2020-05-20 21:44:16,207] DEBUG: worker 0 workng on ptr (lib.py:215)
[2020-05-20 21:44:17,077] INFO: Finished poetry (lib.py:249)
[2020-05-20 21:44:17,077] DEBUG: worker 1 workng on pyramid (lib.py:215)
[2020-05-20 21:44:17,460] INFO: Finished ptr (lib.py:249)
[2020-05-20 21:44:17,460] DEBUG: worker 0 workng on pytest (lib.py:215)
[2020-05-20 21:44:17,460] INFO: Skipping pytest as it's disabled via config (lib.py:222)
[2020-05-20 21:44:17,460] DEBUG: worker 0 workng on sqlalchemy (lib.py:215)
[2020-05-20 21:44:33,319] INFO: Finished pyramid (lib.py:249)
[2020-05-20 21:44:33,319] DEBUG: worker 1 workng on tox (lib.py:215)
[2020-05-20 21:44:42,274] INFO: Finished tox (lib.py:249)
[2020-05-20 21:44:42,275] DEBUG: worker 1 workng on virtualenv (lib.py:215)
[2020-05-20 21:44:47,928] INFO: Finished virtualenv (lib.py:249)
[2020-05-20 21:44:47,928] DEBUG: worker 1 workng on warehouse (lib.py:215)
[2020-05-20 21:45:16,784] INFO: Finished warehouse (lib.py:249)
[2020-05-20 21:45:16,784] DEBUG: project_runner 1 exiting (lib.py:213)
[2020-05-20 21:45:45,700] INFO: Finished sqlalchemy (lib.py:249)
[2020-05-20 21:45:45,700] DEBUG: project_runner 0 exiting (lib.py:213)
[2020-05-20 21:45:45,701] INFO: Analyzing results (lib.py:292)
-- primer results 📊 --

13 / 16 succeeded (81.25%) ✅
0 / 16 FAILED (0.0%) 💩
 - 3 projects disabled by config
 - 0 projects skipped due to Python version
 - 0 skipped due to long checkout
```

* Move to partial for rmtree + specify a onerror handler for PermissionError on Windows for git

* Set default coding to utf8 for very important emoji's on Windows

* Set Python encoding to utf-8 for Windows

* Appease the white space gods of Black!

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
4 years agoFix typos (#1442)
Kevin Kirsche [Thu, 21 May 2020 13:44:43 +0000 (09:44 -0400)]
Fix typos (#1442)

4 years agoblack-primer: handle singular and plural in output messages (#1432)
Hugo van Kemenade [Thu, 21 May 2020 04:03:51 +0000 (07:03 +0300)]
black-primer: handle singular and plural in output messages (#1432)

* Handle singular and plural in output messages

4 years agoUpdate README.md (#1439)
Gustavo Camargo [Thu, 21 May 2020 03:50:16 +0000 (22:50 -0500)]
Update README.md (#1439)

4 years agoAdd `black-primer` docs (#1427)
Cooper Lees [Mon, 18 May 2020 14:25:40 +0000 (07:25 -0700)]
Add `black-primer` docs (#1427)

* Add `black-primer` docs

- Document the idea, CLI args, config and a example run for `black-primer` in README.md
- Add to docs/index.rst

* Add @hugovk suggestions - Thanks.

4 years agoUpdate docs about stable tag now being a branch (#1422)
Richard Si [Sun, 17 May 2020 19:19:52 +0000 (15:19 -0400)]
Update docs about stable tag now being a branch (#1422)

* Update docs about stable tag now being a branch

Issue #760 had the `stable` tag changed to a branch since it was causing a few issues. This updates the docs to reflect that change.

* Make the prettier hook pass

* Improve wording

4 years agoAdd black-primer unittests (#1426)
Cooper Lees [Sun, 17 May 2020 19:18:49 +0000 (12:18 -0700)]
Add black-primer unittests (#1426)

* Add black-primer unittests

- Get this tool covered with some decent unittests for all unittests wins
- Have a CLI and lib test class
- Import it from `test_black.py` so we always run tests
- Revert typing asyncio.Queue as Queue[str] so we can work in 3.6
- **mypy**: Until black > 3.6 disallow_any_generics=False for primer code

Test:
- Run tests: `coverage run tests/test_primer.py` or `coverage run -m unittest`
```
(b) cooper-mbp1:black cooper$ coverage report
Name                      Stmts   Miss  Cover
---------------------------------------------
src/black_primer/cli.py      49      8    84%
src/black_primer/lib.py     148     28    81%
tests/test_primer.py        114      1    99%
---------------------------------------------
TOTAL                       311     37    88%
```

* Use ProactorEventLoop for Windows + fix false path for Linux

* Set Windows to use ProactorEventLoop in  to benefit all callers

* sys.platform seems to not having the loop applied - So type ignore and use platform.system() gate

* Have each test loop correctly set to ProactorEventLoop on Windows for < 3.8 too

4 years agoUpdate and fix Flake8 (#1424)
Hugo van Kemenade [Sun, 17 May 2020 14:18:45 +0000 (17:18 +0300)]
Update and fix Flake8 (#1424)

* Update pre-commit

* Fix F541 f-string is missing placeholders

* Fix E741 ambiguous variable name 'l'

* Update actions to v2

4 years agoFix typos (#1423)
Hugo van Kemenade [Sun, 17 May 2020 14:17:31 +0000 (17:17 +0300)]
Fix typos (#1423)

4 years agoAdd primer CI tool 🏴 (#1402)
Cooper Lees [Sun, 17 May 2020 00:36:20 +0000 (17:36 -0700)]
Add primer CI tool 🏴 (#1402)

* Add primer CI tool 💩
- Run in PATH `black` binary on configured projects
- Can set wether we expect changes or not per project
- Can set what python versions are supported for a project
- if `long_checkout` True project will not be ran on CI

Will add to CI after I finish unit tests to avoid silly bugs I'm sure I have 🤪

Tests:
- Manual Run - Will add unit tests if people think it will be useful
- Output:

```shell
(b) cooper-mbp1:black cooper$ time /tmp/b/bin/black-primer -k -w /tmp/cooper_primer_1
[2020-05-10 08:48:25,696] INFO: 4 projects to run black over (lib.py:212)
[2020-05-10 08:48:25,697] INFO: Skipping aioexabgp as it's disabled via config (lib.py:166)
[2020-05-10 08:48:25,699] INFO: Skipping bandersnatch as it's disabled via config (lib.py:166)
[2020-05-10 08:48:28,676] INFO: Analyzing results (lib.py:225)
-- primer results 📊 --

2 / 4 succeeded (50.0%) ✅
0 / 4 FAILED (0.0%) 💩
 - 2 projects Disabled by config
 - 0 projects skipped due to Python Version
 - 0 skipped due to long checkout

real 0m3.304s
user 0m9.529s
sys 0m1.019s
```

- ls of /tmp/cooper_primer_1
```
(b) cooper-mbp1:black cooper$ ls -lh /tmp/cooper_primer_1
total 0
drwxr-xr-x  21 cooper  wheel   672B May 10 08:48 attrs
drwxr-xr-x  14 cooper  wheel   448B May 10 08:48 flake8-bugbear
```

* Address mypy 3.6 type errors
- Don't use asyncio.run() ... go back to the past :P
- Refactor results into a named tuple of two dicts to avoid typing nightmare
- Fix some variable names
- Fix bug with rebase logic in git_checkout_or_rebase

* Prettier the JSON config file for primer

* Delete projects when finished, move dir to be timestamped + shallow copy

* Re-enable disabled projects post @JelleZijlstra's docstring fix

* Workaround for future annotations until someone tells me the correct fix

4 years agoDocument git's ignore-revs-file feature (#1419)
Richard Si [Sat, 16 May 2020 20:22:46 +0000 (16:22 -0400)]
Document git's ignore-revs-file feature (#1419)

* Document git's ignore-revs-file feature

A long-standing counterargument against moving to automated code formatters
like Black is that the migration will clutter up the output of git blame.
This used to be a valid argument, but not anymore. Since git version 2.23,
git natively supports ignoring revisions in blame with the --ignore-rev
and --ignore-revs-file options.

This isn't documented in the Black documentation. It should be as it would
put old projects wanting to migrate to Black at ease since blame won't
be ruined.

* Add links so people can +1 on --ignore-revs-file support

* Fix wording

'Counterargument' was the wrong word since it means an objection to an objection. 'Argument' is the proper word I was looking for.

Co-authored-by: Cooper Lees <me@cooperlees.com>
4 years agoExpand docs about slice formatting (#1418)
Richard Si [Sat, 16 May 2020 09:21:31 +0000 (05:21 -0400)]
Expand docs about slice formatting (#1418)

Black will apply no spaces around ':' operators for 'simple' expresssions
, but will apply extra space around ':' operators for 'complex' expressions.
Black treats anything more than variable names as 'complex', but this isn't
noted in the Black documentation. Which leads to a few issues on the GitHub
issue tracker that all report inconsistent spacing around ':' operators.

4 years agofix crashes on docstring whitespace changes (#1417)
Jelle Zijlstra [Sat, 16 May 2020 03:47:21 +0000 (20:47 -0700)]
fix crashes on docstring whitespace changes (#1417)

Fixes #1415

4 years agoFix Boolean values in pyproject.toml config (#1410)
Paul Meinhardt [Wed, 13 May 2020 19:51:04 +0000 (21:51 +0200)]
Fix Boolean values in pyproject.toml config (#1410)

Boolean values use lowercase identifiers in TOML.
https://github.com/toml-lang/toml#user-content-boolean

4 years agoRemove no longer used appveyor (#1401)
Cooper Lees [Sat, 9 May 2020 19:16:00 +0000 (12:16 -0700)]
Remove no longer used appveyor (#1401)

4 years agoHandle ImportError from multiprocessing module (#1400)
Terrance [Sat, 9 May 2020 16:22:23 +0000 (17:22 +0100)]
Handle ImportError from multiprocessing module (#1400)

Termux's Python environment doesn't provide sem_open, but fails with a
nested `ImportError` on import attempts:

    ImportError: cannot import name 'SemLock' from '_multiprocessing'

This updates the existing handling for AWS Lambda to catch both
`OSError` and `ImportError`.

4 years agoAdd preference of parantheses over backslashes in docs (#1399)
Sanket Dasgupta [Sat, 9 May 2020 13:32:29 +0000 (19:02 +0530)]
Add preference of parantheses over backslashes in docs (#1399)

Closes https://github.com/psf/black/issues/392

Revived from https://github.com/psf/black/pull/558

Relevant to https://github.com/psf/black/issues/664

4 years agoREADME/CHANGES: Fix links (#1397)
Hugo van Kemenade [Fri, 8 May 2020 19:14:27 +0000 (22:14 +0300)]
README/CHANGES: Fix links (#1397)

* Replace relative README links with absolutes, so they work on PyPI

* CHANGES: Fix Spyder web link

4 years agoAdd py.typed file. (#1395)
Nathan Hunt [Fri, 8 May 2020 16:53:07 +0000 (12:53 -0400)]
Add py.typed file. (#1395)

* Add py.typed file

4 years agoRefactor black into packages in src/ dir (#1376)
Cooper Lees [Fri, 8 May 2020 15:50:50 +0000 (08:50 -0700)]
Refactor black into packages in src/ dir (#1376)

- Move black.py to src/black/__init__.py
- Have setuptools_scm make src/_black_version.py and exclude from git
- Move blackd.py to src/blackd/__init__.py
- Move blib2to3/ to src/
- Update `setup.py`
- Update unittests to pass
  - Mostly path fixing + resolving
- Update CI
  - pre-commit config
  - appveyor + travis

Tested on my mac with python 3.7.5 via:
```
python3 -m venv /tmp/tb3
/tmp/tb3/bin/pip install --upgrade setuptools pip coverage pre-commit
/tmp/tb2/bin/pip install ~/repos/black/
cd ~/repos/black/
/tmp/tb2/bin/coverage run tests/test_black.py
/tmp/tb3/bin/pre-commit run -a
/tmp/tb3/bin/black --help
/tmp/tb3/bin/black ~/repos/ptr/ptr.py
```

4 years agoAdding documentation to the README for import errors in vim (#1317)
shaoran [Fri, 8 May 2020 15:42:19 +0000 (17:42 +0200)]
Adding documentation to the README for import errors in vim (#1317)

* Adding documentation to the README for import errors in vim

I had the same issue as psf/black#1148 and have been searching for a
solution to this. I realized that you cannot fix it by change anything
in the code, but by re-compiling the C extensions of regex and
typed-ast. Installing this packages from the tarballs solves the
problem.

* Fixing a bad copy&paste

Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
* chore: changed made by pre-commit

* chore: better way of dealing with non-binary installs

* chore: adding vim cache files to the ignore list

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
4 years agoAdd purcell/reformatter.el as an Emacs integration option (#1330)
Dan Davison [Fri, 8 May 2020 15:31:06 +0000 (11:31 -0400)]
Add purcell/reformatter.el as an Emacs integration option (#1330)

4 years agoclose event loop for all tests (#1394)
Zsolt Dollenstein [Fri, 8 May 2020 15:27:50 +0000 (16:27 +0100)]
close event loop for all tests (#1394)

4 years agoTest on Python 3.9-dev (#1393)
Hugo van Kemenade [Fri, 8 May 2020 15:19:06 +0000 (18:19 +0300)]
Test on Python 3.9-dev (#1393)

* Test on Python 3.9-dev

* Python 3.9 still in alpha, allow to fail

4 years agoFix mono test
Zsolt Dollenstein [Fri, 8 May 2020 15:13:42 +0000 (16:13 +0100)]
Fix mono test

4 years agoImprove error messages from BlackRunner
Zsolt Dollenstein [Fri, 8 May 2020 15:12:52 +0000 (16:12 +0100)]
Improve error messages from BlackRunner

4 years agoUpdate changelog and README (#1392)
Jelle Zijlstra [Fri, 8 May 2020 14:55:57 +0000 (07:55 -0700)]
Update changelog and README (#1392)

* add two CHANGELOG entries

* update README on command-line options

4 years agoRemove deprecated --py36 option (#1236)
Hugo van Kemenade [Fri, 8 May 2020 14:47:54 +0000 (17:47 +0300)]
Remove deprecated  --py36 option (#1236)

4 years agoadd --force-exclude argument (#1032)
Giacomo Tagliabue [Fri, 8 May 2020 14:47:26 +0000 (10:47 -0400)]
add --force-exclude argument (#1032)

Co-authored-by: Peter Yu <2057325+yukw777@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
4 years agoskip mono test while im working on it
Zsolt Dollenstein [Fri, 8 May 2020 14:36:56 +0000 (15:36 +0100)]
skip mono test while im working on it

4 years agoUpdate CHANGELOG with some PRs merged (#1391)
Cooper Lees [Fri, 8 May 2020 14:29:53 +0000 (07:29 -0700)]
Update CHANGELOG with some PRs merged (#1391)

* Update CHANGELOG with some PRs merged
- Add section for vim plugin
- Add vim plugin now prefering virtualenv
- Add py3 tagged wheels

* packges

* Update CHANGES.md _Black_

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
* Update CHANGES.md Vim

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
4 years agoAdd Black compatible configurations in documentation (#1366 & #1205) (#1371)
Richard Si [Fri, 8 May 2020 14:26:29 +0000 (10:26 -0400)]
Add Black compatible configurations in documentation (#1366 & #1205) (#1371)

* Add Black compatible configs in docs ( #1366 & #1205)

When users of Black are starting a new project or are adding Black to their
existing projects, they will usually have to config their existing tools like
flake8 to be compatible with Black. Usually, these configs are the same across
different projects. Yet, there isn't any consolidated infomation on what configs
are compatible. Leaving users of Black to dig out any infomation they can find
in README.md.

* Fix a bad max-line-length value

* Clean up pylint's configs

* Add explanations for each configurations

Copying and pasting code without understanding it is a bad idea. This goes the same
for users copying and pasting configurations.

* Capitalize Pylint

* Link from the README

* Fix the isort configuration

I referenced the wrong source. I used a pesonal configuration, not a pure Black-
compatible configuration.

* Improve the config explanations

The explanation for the isort configuration was pretty bad. After having fixed the
configuration (see commit 01c55d1), improving the its explanation was necessary to
make it more user-friendly and understandable. Also added fenced code blocks of the
raw configuration options so the explanations make sense.

* Improve README wording slightly

* Add @hugovk, @JelleZijlstra + my suggestions

Co-authored-by: Cooper Lees <cooper@fb.com>
4 years agoInclude an easier way to integrate black with Pycharm (#1268)
Arnav Borborah [Fri, 8 May 2020 14:13:57 +0000 (10:13 -0400)]
Include an easier way to integrate black with Pycharm (#1268)

* Include an easier way to integrate black with Pycharm

4 years agoMake the use of a ThreadPoolExecutor explicit
Łukasz Langa [Fri, 8 May 2020 14:06:05 +0000 (16:06 +0200)]
Make the use of a ThreadPoolExecutor explicit

4 years agobetter test for mono executor
Zsolt Dollenstein [Fri, 8 May 2020 13:54:30 +0000 (14:54 +0100)]
better test for mono executor

4 years agoAdd docstrings to fmt checking functions, add to docs
Autophagy [Fri, 8 May 2020 13:41:27 +0000 (15:41 +0200)]
Add docstrings to fmt checking functions, add to docs

Follow up from #1325

Adds docstrings to the fmt checking functions.
Renames fmt_on to is_fmt_on.
Adds the functions to the autodocs.

4 years agopermits black to run in AWS Lambda: (#1141)
Allan Simon [Fri, 8 May 2020 13:46:07 +0000 (15:46 +0200)]
permits black to run in AWS Lambda: (#1141)

AWS Lambda and some other virtualized environment may not permit access
to /dev/shm on Linux and as such, trying to use ProcessPoolExecutor will
fail.

As using parallelism is only a 'nice to have' feature of black, if it fails
we gracefully fallback to a monoprocess implementation, which permits black
to finish normally.

Co-authored-by: Allan Simon <asimon@yolaw.fr>
4 years agoAdd Change Log project URL (#1382)
Ville Skyttä [Fri, 8 May 2020 13:40:56 +0000 (16:40 +0300)]
Add Change Log project URL (#1382)

* Add Change Log project URL

Co-authored-by: Cooper Lees <me@cooperlees.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
4 years agoPrefer virtualenv packages over global packages (#1383) (#1384)
kaiix [Fri, 8 May 2020 13:31:37 +0000 (21:31 +0800)]
Prefer virtualenv packages over global packages (#1383) (#1384)

4 years agoAdd option for printing a colored diff (#1266)
Douglas Thor [Fri, 8 May 2020 13:30:10 +0000 (06:30 -0700)]
Add option for printing a colored diff (#1266)

4 years agoRemove deprecated use of 'setup.py test' (#1275)
Jon Dufresne [Fri, 8 May 2020 13:23:50 +0000 (06:23 -0700)]
Remove deprecated use of 'setup.py test' (#1275)

Since setuptools v41.5.0 (27 Oct 2019), the 'test' command is formally
deprecated and should not be used. Now use unittest as the test entry
point.

4 years agoAdd Dropbox as a user of Black (#1335)
utsav-dbx [Fri, 8 May 2020 13:23:22 +0000 (06:23 -0700)]
Add Dropbox as a user of Black (#1335)

4 years agoadd bracket check in split_line (#1315)
williamfzc [Fri, 8 May 2020 13:16:57 +0000 (21:16 +0800)]
add bracket check in split_line (#1315)

4 years agoMake sure sys._base_executable is sane in Vim plugin (#1380)
David Lukes [Fri, 8 May 2020 13:13:54 +0000 (15:13 +0200)]
Make sure sys._base_executable is sane in Vim plugin (#1380)

The `venv` module relies on `sys._base_executable` to determine the
Python executable to run, but with recent versions of Vim, this is set
to the `vim` executable. A possible workaround is to just override it,
since the `black` plugin already overrides `sys.executable` (possibly
for similar reasons?) anyway.

4 years agoadd change log entry for #1053
Zsolt Dollenstein [Fri, 8 May 2020 13:09:15 +0000 (14:09 +0100)]
add change log entry for #1053

4 years agoRe-indent the contents of docstrings (#1053)
Alex Vandiver [Fri, 8 May 2020 13:08:15 +0000 (06:08 -0700)]
Re-indent the contents of docstrings (#1053)

* Re-indent the contents of docstrings when indentation changes

Keeping the contents of docstrings completely unchanged when
re-indenting (from 2-space intents to 4, for example) can cause
incorrect docstring indentation:

```
class MyClass:
  """Multiline
  class docstring
  """

  def method(self):
    """Multiline
    method docstring
    """
    pass
```
...becomes:
```
class MyClass:
    """Multiline
  class docstring
  """

    def method(self):
        """Multiline
    method docstring
    """
        pass
```

This uses the PEP 257 algorithm for determining docstring indentation,
and adjusts the contents of docstrings to match their new indentation
after `black` is applied.

A small normalization is necessary to `assert_equivalent` because the
trees are technically no longer precisely equivalent -- some constant
strings have changed.  When comparing two ASTs, whitespace after
newlines within constant strings is thus folded into a single space.

Co-authored-by: Luka Zakrajšek <luka@bancek.net>
* Extract the inner `_v` method to decrease complexity

This reduces the cyclomatic complexity to a level that makes flake8 happy.

* Blacken blib2to3's docstring which had an over-indent

Co-authored-by: Luka Zakrajšek <luka@bancek.net>
Co-authored-by: Zsolt Dollenstein <zsol.zsol@gmail.com>
4 years agoAdd error on non-list target-version in config file (#1284)
Andrew Zhou [Fri, 8 May 2020 13:01:42 +0000 (08:01 -0500)]
Add error on non-list target-version in config file (#1284)

4 years agoImprove String Handling (#1132)
Bryan Bugyi [Fri, 8 May 2020 12:56:21 +0000 (08:56 -0400)]
Improve String Handling (#1132)

This pull request's main intention is to wraps long strings (as requested by #182); however, it also provides better string handling in general and, in doing so, closes the following issues:

Closes #26
Closes #182
Closes #933
Closes #1183
Closes #1243

4 years agoMove to 'py3' tagged wheels (#1388)
Cooper Lees [Fri, 8 May 2020 12:49:51 +0000 (05:49 -0700)]
Move to 'py3' tagged wheels (#1388)

- This makes black wheels to be tagged as py3 default
- `python_requires=">=3.6"` ensures we are >= 3.6

Test:
```
python3 -m venv /tmp/build_black
/tmp/build_black/bin/pip install --upgrade pip setuptools wheel
/tmp/build_black/bin/python setup.py bdist_wheel
...
black-19.10b1.dev53+g81bf9bb.d20200508-py3-none-any.whl
```

Addresses #1385

4 years agoFix for "# fmt: on" with decorators (#1325)
otstrel [Fri, 8 May 2020 12:37:17 +0000 (15:37 +0300)]
Fix for "# fmt: on" with decorators (#1325)

4 years agoIssue 1144: Fix type annotations for --config option (#1166)
Vlad Emelianov [Fri, 8 May 2020 12:10:04 +0000 (14:10 +0200)]
Issue 1144: Fix type annotations for --config option (#1166)

4 years agoBump bleach from 3.1.2 to 3.1.4 (#1326)
dependabot[bot] [Fri, 8 May 2020 11:31:46 +0000 (04:31 -0700)]
Bump bleach from 3.1.2 to 3.1.4 (#1326)

Bumps [bleach](https://github.com/mozilla/bleach) from 3.1.2 to 3.1.4.
- [Release notes](https://github.com/mozilla/bleach/releases)
- [Changelog](https://github.com/mozilla/bleach/blob/master/CHANGES)
- [Commits](https://github.com/mozilla/bleach/compare/v3.1.2...v3.1.4)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
4 years agoChange exit code to 2 when config file doesn't exist (#1361)
Toby Fleming [Thu, 30 Apr 2020 07:47:52 +0000 (00:47 -0700)]
Change exit code to 2 when config file doesn't exist (#1361)

Fixes #1360, where an invalid config file causes a return/exit code of 1. This
change means this case is caught earlier, treated like any other bad
parameters, and results in an exit code of 2.

Co-authored-by: Toby Fleming <tobywf@users.noreply.github.com>
4 years agoFixing the documentation of how to install the vim plugin (#1318)
shaoran [Fri, 24 Apr 2020 02:32:40 +0000 (04:32 +0200)]
Fixing the documentation of how to install the vim plugin (#1318)

* fix: Fixing the documentation of how to install the vim plugin

Solves the installation problem that currently exist because
the current master branch is not stable. See psf/black#1304 for
more information.

* fix: fixing incorrect path

4 years agoUpdate heredoc marker case to conform with vim patch 8.1.1723 (#1348)
Charles [Fri, 17 Apr 2020 02:26:09 +0000 (09:26 +0700)]
Update heredoc marker case to conform with vim patch 8.1.1723 (#1348)

4 years agoSmall nitpicks (#1340)
MomIsBestFriend [Sun, 12 Apr 2020 03:30:24 +0000 (06:30 +0300)]
Small nitpicks (#1340)

Co-authored-by: MomIsBestFriend <>
4 years agoFix --diff output when encountering EOF (#1328)
Rémi Verschelde [Sun, 5 Apr 2020 05:02:57 +0000 (07:02 +0200)]
Fix --diff output when encountering EOF (#1328)

`split("\n")` includes a final empty element `""` if the final line
ends with `\n` (as it should for POSIX-compliant text files), which
then became an extra `"\n"`.

`splitlines()` solves that, but there's a caveat, as it will split
on other types of line breaks too (like `\r`), which may not be
desired.

Fixes #526.

4 years agoOmit commit hash and date stamp from doc version (#1322)
Zsolt Dollenstein [Sun, 29 Mar 2020 02:06:00 +0000 (03:06 +0100)]
Omit commit hash and date stamp from doc version (#1322)

This also removes the dependency on setuptools-scm while building the
docs.

Fixes #1104.

4 years agoAdd missing separator in README (#1320)
Quentin Pradet [Fri, 27 Mar 2020 17:28:10 +0000 (21:28 +0400)]
Add missing separator in README (#1320)

4 years agoFix readthedocs build (#1321)
Zsolt Dollenstein [Fri, 27 Mar 2020 10:43:41 +0000 (10:43 +0000)]
Fix readthedocs build (#1321)

* migrate to new rtd config format and pip

* no type field anymore

* use builtin re for docs

4 years agoBump bleach from 3.1.1 to 3.1.2 (#1313)
dependabot[bot] [Fri, 27 Mar 2020 08:24:51 +0000 (08:24 +0000)]
Bump bleach from 3.1.1 to 3.1.2 (#1313)

Bumps [bleach](https://github.com/mozilla/bleach) from 3.1.1 to 3.1.2.
- [Release notes](https://github.com/mozilla/bleach/releases)
- [Changelog](https://github.com/mozilla/bleach/blob/master/CHANGES)
- [Commits](https://github.com/mozilla/bleach/compare/v3.1.1...v3.1.2)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
4 years agoDon't suggest using `sudo` with Docker
Łukasz Langa [Tue, 17 Mar 2020 10:35:41 +0000 (11:35 +0100)]
Don't suggest using `sudo` with Docker

Thanks for the tip, @imomaliev.

4 years agoCompress RUN statements into one to avoid layer proliferation
Łukasz Langa [Tue, 17 Mar 2020 10:33:57 +0000 (11:33 +0100)]
Compress RUN statements into one to avoid layer proliferation

Thanks for the suggestion, @imomaliev.

4 years agoUpdate dependencies
Łukasz Langa [Tue, 17 Mar 2020 10:33:02 +0000 (11:33 +0100)]
Update dependencies

4 years agoFix typo in README (#1306)
Max Smolens [Thu, 12 Mar 2020 19:42:17 +0000 (15:42 -0400)]
Fix typo in README (#1306)

4 years agoUpdate wording and formatting (#1302)
Hugo van Kemenade [Mon, 9 Mar 2020 15:32:27 +0000 (17:32 +0200)]
Update wording and formatting (#1302)

4 years agoImplement Black Version Gallery (#1294)
Batuhan Taşkaya [Mon, 9 Mar 2020 13:42:26 +0000 (16:42 +0300)]
Implement Black Version Gallery (#1294)

Closes #1290.

4 years ago[README.md] Updated Mail Address - Abdur-Rahmaan Janhangeer (#1301)
Abdur-Rahmaan Janhangeer [Mon, 9 Mar 2020 13:38:54 +0000 (17:38 +0400)]
[README.md] Updated Mail Address - Abdur-Rahmaan Janhangeer (#1301)

4 years agoUpdate the name of Mode in the reference docs, too
Łukasz Langa [Wed, 4 Mar 2020 22:19:21 +0000 (23:19 +0100)]
Update the name of Mode in the reference docs, too

4 years agoRename FileMode into just Mode
Łukasz Langa [Wed, 4 Mar 2020 22:16:55 +0000 (23:16 +0100)]
Rename FileMode into just Mode

The mode was never just about files to begin with.  There are no other modes in
Black, this can be the default one.

4 years agoDocument how to use format_str()
Łukasz Langa [Wed, 4 Mar 2020 22:08:57 +0000 (23:08 +0100)]
Document how to use format_str()

Closes #1064

4 years agoIntroduce a section of docs about exceptions
Łukasz Langa [Wed, 4 Mar 2020 21:26:45 +0000 (22:26 +0100)]
Introduce a section of docs about exceptions

4 years agoRun prettier and fix whitespace on CHANGES.md (#1296)
Łukasz Langa [Wed, 4 Mar 2020 18:10:17 +0000 (19:10 +0100)]
Run prettier and fix whitespace on CHANGES.md (#1296)

4 years agoAdd @cooperlees to maintainers
Łukasz Langa [Wed, 4 Mar 2020 15:57:24 +0000 (16:57 +0100)]
Add @cooperlees to maintainers

Fixes #1295

4 years agoTell people where Change Log went
Łukasz Langa [Wed, 4 Mar 2020 15:46:20 +0000 (16:46 +0100)]
Tell people where Change Log went

4 years agoSplit out Change Log (#1117)
Cooper Lees [Wed, 4 Mar 2020 15:40:48 +0000 (15:40 +0000)]
Split out Change Log (#1117)

* Split out Change Log
- Move to CHANGES.md to allow bots to see changes
- MANIFEST.in already includes *.md so CHANGES.md will be included
- THis maintains format but the change log will now be after acknowledgements
- This also ensure this gets added to pypi.org via setup.py function

4 years agostring prefixes: don't normalise capital R-strings (#1271)
Shantanu [Tue, 3 Mar 2020 13:55:14 +0000 (05:55 -0800)]
string prefixes: don't normalise capital R-strings (#1271)

Resolves #1244

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
4 years agoNotify users of missing Python lazily (#1210)
Paul Ganssle [Tue, 3 Mar 2020 12:00:52 +0000 (07:00 -0500)]
Notify users of missing Python lazily (#1210)

Currently this message shows up with no context prior to the start of
Vim. By changing this to a lazy message, the user will only be notified
of a problem with the Black plugin when they are attempting to use the
Black plugin.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
4 years agoTeach the Vim plugin to respect pyproject.toml (issue 414) (#1273)
Tal Amuyal [Tue, 3 Mar 2020 11:23:28 +0000 (13:23 +0200)]
Teach the Vim plugin to respect pyproject.toml (issue 414) (#1273)

Creates two separate functions:

1) abspath_pyproject_toml: find the absolute path to pyproject.toml
2) parse_pyproject_toml: finds black-specific toml config

Co-authored-by: Samuel Roeca <samuel.roeca@gmail.com>
4 years agoSimplify Line.contains_multiline_strings method (#1267)
Yurii Karabas [Sun, 9 Feb 2020 21:21:46 +0000 (00:21 +0300)]
Simplify Line.contains_multiline_strings method (#1267)

4 years agoUpdate README.md to include appropriate command to install Vim with Python 3 on macOS...
Shinya Fujino [Sun, 26 Jan 2020 13:31:49 +0000 (22:31 +0900)]
Update README.md to include appropriate command to install Vim with Python 3 on macOS (#1247)

* Update README.md to include appropriate command to install Vim with Python 3 on macOS

* Run pre-commit hooks

4 years agoChange error message to specify its origin. (#1240)
Matthew Clapp [Thu, 23 Jan 2020 16:18:57 +0000 (08:18 -0800)]
Change error message to specify its origin. (#1240)

4 years agoSupport py38-style starred expressions in return statement (#1121)
Vlad Emelianov [Sat, 18 Jan 2020 15:21:46 +0000 (16:21 +0100)]
Support py38-style starred expressions in return statement (#1121)

4 years agoRemove unused variables tokenprog, Token and PlainToken (#1137)
Jon Dufresne [Sat, 18 Jan 2020 15:21:19 +0000 (07:21 -0800)]
Remove unused variables tokenprog, Token and PlainToken (#1137)

4 years agochange pyproject.toml relative path to absolute path in README.md (#1152)
Yazdan [Sat, 18 Jan 2020 15:19:54 +0000 (18:49 +0330)]
change pyproject.toml relative path to absolute path in README.md (#1152)

because in the readthedocs hosted version this pyproject.toml will route to readthedocs does not exist page

4 years agoAdd comment to flake8 configuration explaining line-length mismatch (#1206)
Michael Aquilina [Sat, 18 Jan 2020 15:17:06 +0000 (17:17 +0200)]
Add comment to flake8 configuration explaining line-length mismatch (#1206)

4 years agoUse conditional case for diff reports (#1226)
kyle hausmann [Sat, 18 Jan 2020 15:13:15 +0000 (10:13 -0500)]
Use conditional case for diff reports (#1226)

When --diff flag is used, black will now use the
conditional case in the Report output: eg "would
be reformatted"

4 years agobump regex version, providing wheels (#1232)
Mr. Outis [Sat, 18 Jan 2020 15:12:24 +0000 (09:12 -0600)]
bump regex version, providing wheels (#1232)

Close #1112

4 years agofind_project_root: allow .git to be a file (#1217)
hauntsaninja [Thu, 2 Jan 2020 22:33:30 +0000 (14:33 -0800)]
find_project_root: allow .git to be a file (#1217)

Fixes #1213

4 years agoSkip the broken version of regex (#1209)
Hugo van Kemenade [Mon, 16 Dec 2019 21:46:44 +0000 (23:46 +0200)]
Skip the broken version of regex (#1209)

4 years agoThis MANIFEST.in not needed with setuptools_scm (#1200)
Hugo van Kemenade [Wed, 11 Dec 2019 10:23:26 +0000 (12:23 +0200)]
This MANIFEST.in not needed with setuptools_scm (#1200)

4 years agoAdd Thonny-black-code-format plugin (#1195)
Francisco [Sun, 8 Dec 2019 18:13:50 +0000 (18:13 +0000)]
Add Thonny-black-code-format plugin (#1195)