]> 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 agoStability fixup: interaction between newlines and comments (#1975)
James Addison [Thu, 11 Feb 2021 20:11:42 +0000 (20:11 +0000)]
Stability fixup: interaction between newlines and comments (#1975)

* Add test case to illustrate the issue

* Accept carriage returns as valid separators while enumerating comments

Without this acceptance, escaped multi-line statments that use carriage returns will not be counted into the 'ignored_lines' variable since the emitted line values will end with a CR and not an escape character.  That leads to comments associated with the line being incorrectly labeled with the STANDALONE_COMMENT type, affecting comment placement and line space management.

* Remove comment linking to ephemeral build log

3 years agoBump cryptography from 3.3.1 to 3.3.2 (#1981)
dependabot[bot] [Wed, 10 Feb 2021 02:17:23 +0000 (18:17 -0800)]
Bump cryptography from 3.3.1 to 3.3.2 (#1981)

Bumps [cryptography](https://github.com/pyca/cryptography) from 3.3.1 to 3.3.2.
- [Release notes](https://github.com/pyca/cryptography/releases)
- [Changelog](https://github.com/pyca/cryptography/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pyca/cryptography/compare/3.3.1...3.3.2)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years agoRegenerate documentation (#1980)
James Addison [Wed, 10 Feb 2021 01:10:02 +0000 (01:10 +0000)]
Regenerate documentation (#1980)

Resolves #1979 and ensures that the content from #1861 is included in the repository-published documentation.

3 years agoUpdate prettier in pre-commit config (#1966)
Richard Si [Fri, 5 Feb 2021 04:10:45 +0000 (23:10 -0500)]
Update prettier in pre-commit config (#1966)

With older versions of prettier, when the hook failed a bunch of
"[error] No parser could be inferred for file: {PATH}" error lines
showed up because of lack of support of a flag that pre-commit
passes for us by default. It made figuring out why the prettier hook
failed annoying.

3 years agospeed up cache by approximately 42x by avoiding pathlib (#1953)
Anthony Sottile [Thu, 4 Feb 2021 21:03:42 +0000 (13:03 -0800)]
speed up cache by approximately 42x by avoiding pathlib (#1953)

3 years agoBump bleach from 3.2.1 to 3.3.0 (#1957)
dependabot[bot] [Tue, 2 Feb 2021 23:54:14 +0000 (15:54 -0800)]
Bump bleach from 3.2.1 to 3.3.0 (#1957)

Bumps [bleach](https://github.com/mozilla/bleach) from 3.2.1 to 3.3.0.
- [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.2.1...v3.3.0)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years agoRemove placeholder exit code in unreachable 'black-primer' subprocess handler (#1952)
James Addison [Mon, 1 Feb 2021 17:54:19 +0000 (17:54 +0000)]
Remove placeholder exit code in unreachable 'black-primer' subprocess handler (#1952)

3 years agoUpdate example exclude to match only files in root (#1861)
Oliver Newman [Wed, 27 Jan 2021 17:36:21 +0000 (12:36 -0500)]
Update example exclude to match only files in root (#1861)

* Update example exclude to match only files in root

The `exclude` section of the example `pyproject.toml` file didn't work
as expected. It claimed to exclude matched files only in the project
root, but it actually excluded matched files at any directory level
within the project. We can address this by prepending `^/` to the regex
to ensure that it only matches files in the project root.

See https://github.com/psf/black/issues/1473#issuecomment-740008873 for
explanation.

* Mention excluding directories as well

3 years agoAdd --skip-magic-trailing-comma (#1824)
Shantanu [Mon, 18 Jan 2021 00:59:06 +0000 (16:59 -0800)]
Add --skip-magic-trailing-comma (#1824)

3 years agoOSS-Fuzz integration (#1930)
Zac Hatfield-Dodds [Sat, 16 Jan 2021 00:05:15 +0000 (11:05 +1100)]
OSS-Fuzz integration (#1930)

3 years agoFix typo (#1931)
Emilv2 [Fri, 15 Jan 2021 22:43:23 +0000 (23:43 +0100)]
Fix typo (#1931)

3 years agoUpdate link pointing to how-black-wraps-lines (#1925)
Peter Stensmyr [Thu, 14 Jan 2021 23:57:45 +0000 (10:57 +1100)]
Update link pointing to how-black-wraps-lines (#1925)

The section about the Black code style has been moved to its own file.
Update link on the compatible configs page to point to the right place.

3 years agoUpdate Contributing Docs (#1915)
Cooper Lees [Wed, 13 Jan 2021 23:17:30 +0000 (15:17 -0800)]
Update Contributing Docs (#1915)

* Update Contributing Docs
- Update docs with all new tox hotness
- Test running docs build:
  - `sphinx-build -a -b html -W docs/ docs/_build/`

Fixes #1907

* Fix docs/contributing_to_black.md lint

* Remove autogenerated copy pasta

* Fix review typos + regen automated docs via Running Sphinx v1.8.5

3 years agoSet gh action entrypoint interpreter to bash (#1919)
Thomas Hagebols [Mon, 11 Jan 2021 16:23:11 +0000 (17:23 +0100)]
Set gh action entrypoint interpreter to bash (#1919)

3 years agofix #1917 (#1918)
Shota Ray Imaki [Mon, 11 Jan 2021 16:21:14 +0000 (01:21 +0900)]
fix #1917 (#1918)

3 years agoChanged max workers on windows to 60 (#1912)
Troy Murray [Fri, 8 Jan 2021 20:26:42 +0000 (07:26 +1100)]
Changed max workers on windows to 60 (#1912)

3 years agoRelease gh action (#1909)
Rick Staa [Fri, 8 Jan 2021 19:47:03 +0000 (20:47 +0100)]
Release gh action (#1909)

* Gets gh-action ready for marketplace release

* Updates documentation and removes redundant gh-action input argument

* Fixes gh-action bug

This commit fixes a bug which caused not all input arguments were forwarder to the black formatter.

* Update README.md

Co-authored-by: Cooper Lees <me@cooperlees.com>
Co-authored-by: Cooper Lees <me@cooperlees.com>
3 years agoOnly require typing-extensions if Python < 3.8 (#1873)
Taneli Hukkinen [Sun, 3 Jan 2021 16:14:59 +0000 (17:14 +0100)]
Only require typing-extensions if Python < 3.8 (#1873)

3 years agoUse Prettier pre-commit mirror (#1896)
Paul "TBBle" Hampson [Fri, 1 Jan 2021 18:54:35 +0000 (05:54 +1100)]
Use Prettier pre-commit mirror (#1896)

This fixes Prettier install failures similar to those seen in
https://github.com/prettier/prettier/issues/9459, and is the solution
recommended there.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
3 years agoBump minimum_pre_commit_version per recommendation (#1895)
Jon Dufresne [Thu, 31 Dec 2020 19:10:18 +0000 (11:10 -0800)]
Bump minimum_pre_commit_version per recommendation (#1895)

Recommended by @asottile, the pre-commit author and maintainer, to avoid
some breakages in version 2.9.0.

3 years agoAdd pyi file support to .pre-commit-hooks.yaml (#1875)
Jon Dufresne [Thu, 31 Dec 2020 17:09:07 +0000 (09:09 -0800)]
Add pyi file support to .pre-commit-hooks.yaml (#1875)

Since pre-commit 2.9.0 (2020-11-21), the types_or key can be used to
match multiple disparate file types. For more upstream details, see:
https://github.com/pre-commit/pre-commit/issues/607

Add the minimum_pre_commit_version to require pre-commit 2.9.0+.

Fixes #402

3 years agoBump typed-ast to fix for s390x (#1892)
Hugo van Kemenade [Thu, 31 Dec 2020 17:07:31 +0000 (19:07 +0200)]
Bump typed-ast to fix for s390x (#1892)

* Bump typed-ast to fix for s390x

* pipenv install typed-ast==1.4.2

3 years agoAs long as it's black (#1893)
Hugo van Kemenade [Thu, 31 Dec 2020 17:03:39 +0000 (19:03 +0200)]
As long as it's black (#1893)

Make background transparent for dark mode

3 years agoFix INTERNAL ERROR caused by removing parens from pointless string (#1888)
Bryan Bugyi [Mon, 28 Dec 2020 20:30:23 +0000 (15:30 -0500)]
Fix INTERNAL ERROR caused by removing parens from pointless string (#1888)

Fixes #1846.

3 years agoBump mypy to 0.780 in pre-commit config (#1887)
Richard Si [Mon, 28 Dec 2020 02:38:11 +0000 (21:38 -0500)]
Bump mypy to 0.780 in pre-commit config (#1887)

To avoid hitting a mypy bug causes pre-commit to always fail on CPython
3.9. Even though it's still an outdated version, the bug effectively
blocks development on CPython 3.9 so that's why this commit exists
instead of waiting for cooperlees to finish his bump to 0.790 PR.

Also this fixes primer to ensure it always raises CalledProcessError
with an int error code. I stole the patch from cooperlees's mypy bump
PR.

It's funny how mypy 0.790 is already asked for in our
Pipfile.lock file, but oh well mypy is probably more commonly run
through pre-commit than standalone I guess.

Oh and if you're curious why the bug doesn't up on CPython 3.8 or lower:
there was some subscription AST changes in CPython 3.9.

3 years agoFuzz on Python 3.9 too (#1882)
Richard Si [Sun, 27 Dec 2020 15:19:08 +0000 (10:19 -0500)]
Fuzz on Python 3.9 too (#1882)

Fuzzing on Python 3.9 used to cause errors but now they have disappeared
on more modern Python 3.9 and Hypothesmith.

3 years agofix format_str() docstring to prevent users from running into NameError (#1885)
nikkie [Sun, 27 Dec 2020 15:18:35 +0000 (00:18 +0900)]
fix format_str() docstring to prevent users from running into NameError (#1885)

3 years agoRemove all trace of flake8-mypy (#1867)
Shantanu [Mon, 14 Dec 2020 07:20:25 +0000 (23:20 -0800)]
Remove all trace of flake8-mypy (#1867)

flake8-mypy is long dead and shouldn't be used, see
https://github.com/ambv/flake8-mypy. We appear to use pre-commit to run
mypy now anyway.

I ran `pipenv uninstall flake8-mypy`, which seems to have made several
changes to Pipfile.lock. Let me know if there's a better way to do this.

Co-authored-by: hauntsaninja <>
3 years agovim plugin: Add quiet flag so non-error actions go unreported (#1733)
Noel Evans [Wed, 9 Dec 2020 23:40:45 +0000 (23:40 +0000)]
vim plugin: Add quiet flag so non-error actions go unreported (#1733)

4 years agoSwitch back to Python 3.8 for ReadTheDocs (#1839)
Richard Si [Thu, 26 Nov 2020 00:26:35 +0000 (19:26 -0500)]
Switch back to Python 3.8 for ReadTheDocs (#1839)

ReadTheDocs doesn't support Python 3.9 yet.

4 years agoAllow same RHS expressions in annotated assignments as in regular assignments (#1835)
Richard Si [Tue, 24 Nov 2020 09:39:25 +0000 (04:39 -0500)]
Allow same RHS expressions in annotated assignments as in regular assignments (#1835)

4 years agoProvide a stdin-filename to allow stdin to respect force-exclude rules (#1780)
Thiago Bellini Ribeiro [Fri, 13 Nov 2020 15:26:07 +0000 (12:26 -0300)]
Provide a stdin-filename to allow stdin to respect force-exclude rules (#1780)

* Provide a stdin-filename to allow stdin to respect exclude/force-exclude rules

This will allow automatic tools to enforce the project's
exclude/force-exclude rules even if they pass the file through stdin to
update its buffer.

This is a similar solution to --stdin-display-name in flake8.

* Update src/black/__init__.py

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
* --stdin-filename should only respect --exclude-filename

* Update README with the new --stdin-filename option

* Write some tests for the new stdin-filename functionality

* Apply suggestions from code review

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
* Force stdin output when we asked for stdin even if the file exists

* Add an entry in the changelog regarding --stdin-filename

* Reduce disk reads if possible

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
* Check for is_stdin and p.is_file before checking for p.is_dir()

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
4 years agoUse lowercase hex numbers fixes #1692 (#1775)
Casper Weiss Bang [Fri, 13 Nov 2020 15:25:17 +0000 (16:25 +0100)]
Use lowercase hex numbers fixes #1692 (#1775)

* Made hex lower case

* Refactored numeric formatting section

* Redid some refactoring and removed bloat

* Removed additions from test_requirements.txt

* Primer now expects expected changes

* Undid some refactoring

* added to changelog

* Update src/black/__init__.py

Co-authored-by: Zsolt Dollenstein <zsol.zsol@gmail.com>
Co-authored-by: Zsolt Dollenstein <zsol.zsol@gmail.com>
Co-authored-by: Cooper Lees <me@cooperlees.com>
4 years agoCorrectly handle inline tabs in docstrings (#1810)
Justin Prieto [Mon, 9 Nov 2020 19:58:23 +0000 (14:58 -0500)]
Correctly handle inline tabs in docstrings (#1810)

The `fix_docstring` function expanded all tabs, which caused a
difference in the AST representation when those tabs were inline and not
leading. This changes the function to only expand leading tabs so inline
tabs are preserved.

Fixes #1601.

4 years agoFix bug which causes f-expressions to be split (#1809)
Bryan Bugyi [Sat, 7 Nov 2020 00:17:23 +0000 (19:17 -0500)]
Fix bug which causes f-expressions to be split (#1809)

Closes #1807.

4 years agoAutomatically build and upload binaries on release (#1743)
Richard Si [Sun, 1 Nov 2020 21:17:23 +0000 (16:17 -0500)]
Automatically build and upload binaries on release (#1743)

This commit adds a new GitHub Actions workflow that builds self-contained
binaries / executables and uploads them as release assets to the triggering
release. Publishing a release, drafting one doesn't count, will trigger this
workflow.

I personally used GitHub Actions only because it's the CI/CD platform(?)
I am familiar with. Only Windows and Linux binaries are supported since
I don't have any systems running Mac OS.

For Linux, I had originally planned to use the manylinux2010 docker image
the PyPA provides for highly compatible wheel building, but unfortunately
it wasn't feasible due to GitHub Actions and PyInstaller incompatibilities.
As a stopgap the oldest versions of Linux and Windows are used although
Windows Server 2019 isn't that old nor is Ubuntu 16.04! I guess someone
(maybe me) could work out something else if compatibility is big problem.

A few things you should know about the workflow:
 - You don't need to set the `GITHUB_TOKEN` secret as it is automatically
   provided by GitHub.
 - matrix.pathsep is used because PyInstaller configuration's format is OS
   dependent for some reason ...

Also it's worth mentioning that Black once had Travis CI and AppVeyor
configuration that did the same thing as this commit. They were committed
in mid 2018 and worked (somewhat) well. Eventually we stopped using AppVeyor
and the refactor to packages broke the Travis CI config. This commit
replaces the still existing and broken Travis CI config wholesale.

Co-authored-by: Anders Fredrik Kiær <31612826+anders-kiaer@users.noreply.github.com>
 - Anders told me that I could get the release asset upload URL directly
   from the github.event.release payload. I originally planned to use
   bruceadams/get-release to get such URL.

4 years agoFix bug where black tries to split string on escaped space (#1799)
Bryan Bugyi [Sat, 31 Oct 2020 17:42:36 +0000 (13:42 -0400)]
Fix bug where black tries to split string on escaped space (#1799)

Closes #1505.

4 years agoStart using Python 3.9 on Travis (#1790)
Abdullah Selek [Fri, 30 Oct 2020 15:24:18 +0000 (15:24 +0000)]
Start using Python 3.9 on Travis (#1790)

* Start using Python 3.9 on Travis

* Remove allow_failures

4 years agoBump cryptography from 3.1 to 3.2 (#1791)
dependabot[bot] [Fri, 30 Oct 2020 15:15:09 +0000 (08:15 -0700)]
Bump cryptography from 3.1 to 3.2 (#1791)

Bumps [cryptography](https://github.com/pyca/cryptography) from 3.1 to 3.2.
- [Release notes](https://github.com/pyca/cryptography/releases)
- [Changelog](https://github.com/pyca/cryptography/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pyca/cryptography/compare/3.1...3.2)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
4 years agoAdd compatible configuration files. (psf#1789) (#1792)
Shota Ray Imaki [Fri, 30 Oct 2020 15:13:55 +0000 (00:13 +0900)]
Add compatible configuration files. (psf#1789) (#1792)

* Add compatible configuration files. (psf#1789)

* Simplify isort configuration files. (#1789)

4 years agoExtract formatting tests (#1785)
Sagi Shadur [Fri, 30 Oct 2020 15:12:04 +0000 (17:12 +0200)]
Extract formatting tests (#1785)

* Update test versions

* Use parametrize to remove tests duplications

* Extract sources format tests

* Fix mypy errors

* Fix .travis.yml

4 years agoDocument some culprits with pre-commit (#1783)
Bibo-Joshi [Tue, 27 Oct 2020 20:59:43 +0000 (21:59 +0100)]
Document some culprits with pre-commit (#1783)

* Document some culprits with pre-commit

* make pre-commit happy

* don't use monospace for black & pre-commit

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
* make pre-commit happy again

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
4 years agoUpdate readme.md with current version (#1788)
Antek S [Tue, 27 Oct 2020 10:52:19 +0000 (11:52 +0100)]
Update readme.md with current version (#1788)

* Update readme.md with current version

* Update version_control_integration.md

4 years agoSwitch to pytest and tox (#1763)
Sagi Shadur [Mon, 19 Oct 2020 17:35:26 +0000 (20:35 +0300)]
Switch to pytest and tox (#1763)

* Add venv to .gitignore

* Use tox to run tests

* Make fuzz run in tox

* Split tests files

* Fix import error

4 years agoUpdate PyCharm integrations instructions to avoid running on external changes (#1769)
johnthagen [Mon, 19 Oct 2020 17:34:42 +0000 (13:34 -0400)]
Update PyCharm integrations instructions to avoid running on external changes (#1769)

4 years agoFix GitHub markdown links to work on RTD (#1752)
David W.H. Swenson [Sun, 18 Oct 2020 21:27:15 +0000 (23:27 +0200)]
Fix GitHub markdown links to work on RTD (#1752)

* Fix internal links to work on RTD

Note that these still lead to GitHub, instead of staying on RTD.

* Point links to better anchors

4 years agoAllow black's Github action params overriding. (#1755)
Hadi Alqattan [Sun, 18 Oct 2020 21:24:33 +0000 (00:24 +0300)]
Allow black's Github action params overriding. (#1755)

* Allow default params overriding.

* Update: docs and action.yaml.

* The second contirbution, add my name to authors.md

* Correct docs `with.args` example.

* Just to rerun the Travis jobs.

* chmod 755

4 years agoAdd blackd to nicely exit if missing aiohttp deps (#1761)
Cooper Lees [Tue, 13 Oct 2020 05:03:00 +0000 (22:03 -0700)]
Add blackd to nicely exit if missing aiohttp deps (#1761)

- If no aiohttp* deps exist nicely print a helpful message and exit
- There seems to be no nice way to optionally install the entry point, so lets make the entry point nicer

Test:
```
cooper-mbp1:black cooper$ /tmp/tb/bin/pip install .
cooper-mbp1:black cooper$ /tmp/tb/bin/blackd
aiohttp dependency is not installed: No module named 'aiohttp'. Please re-install black with the '[d]' extra install  to obtain aiohttp_cors: `pip install black[d]`
cooper-mbp1:black cooper$ /tmp/tb/bin/pip install .[d]
...
Successfully installed aiohttp-3.6.3 aiohttp-cors-0.7.0 black
cooper-mbp1:black cooper$ /tmp/tb/bin/blackd
blackd version 20.8b2.dev31+gdd2f86a.d20201013 listening on localhost port 45484
```

Fixes #1688

4 years agoSupport stable Python3.9. (#1748)
Hadi Alqattan [Thu, 8 Oct 2020 21:13:13 +0000 (00:13 +0300)]
Support stable Python3.9. (#1748)

* Support stable Python3.9.

* Get back to 3.9-dev

* Add py39 to black usage.

* remove 3.9 temporarily.

4 years agodocs: update `used-by` link to proper url (#1745)
Cha Gyuseok [Wed, 7 Oct 2020 14:45:06 +0000 (23:45 +0900)]
docs: update `used-by` link to proper url (#1745)

4 years agoPrimer: pyramid and sqlalchemy are now formatted with latest Black (#1736)
Hugo van Kemenade [Fri, 2 Oct 2020 11:47:57 +0000 (14:47 +0300)]
Primer: pyramid and sqlalchemy are now formatted with latest Black (#1736)

4 years agoFix unnecessary if checks (#1728)
Hakan Çelik [Mon, 28 Sep 2020 19:55:35 +0000 (22:55 +0300)]
Fix unnecessary if checks (#1728)

4 years agoHypothesis is now formatted with Black 20.8b1 (#1729)
Hugo van Kemenade [Mon, 28 Sep 2020 02:42:01 +0000 (05:42 +0300)]
Hypothesis is now formatted with Black 20.8b1 (#1729)

4 years agoRepair colorama wrapping on non-Windows platforms (#1670)
Pete Grayson [Sun, 27 Sep 2020 21:41:11 +0000 (21:41 +0000)]
Repair colorama wrapping on non-Windows platforms (#1670)

* Repair colorama wrapping on non-Windows platforms

The wrap_stream_for_windows() function calls
colorama.initialise.wrap_stream() function to apply colorama's magic to
wrapper to the output stream. Except this wrapper is only applied on
Windows platforms that need it, otherwise the original stream is
returned as-is.

The colorama wrapped stream lacks a detach() method, so a no-op lambda
was being assigned to the wrapped stream.

The problem is that the no-op lambda was being assigned unconditionally
whether or not colorama actually returns a wrapped stream, thus
replacing the original TextIOWrapper's detach() method. Replacing the
detach() method with a no-op lambda is the root cause of the problem
observed in #1664.

The solution is to only assign the no-op detach() method if the stream
lacks its own detach() method.

Repairs #1664

4 years agoEnd 'force-exclude' help message with a period (#1727)
Vipul [Sun, 27 Sep 2020 05:54:21 +0000 (05:54 +0000)]
End 'force-exclude' help message with a period (#1727)

It would be nice, if like other options help message, force-exclude's
help message also ends with a period punctuation mark.

4 years agoPEP 614 support (#1717)
QuentinSoubeyran [Sat, 19 Sep 2020 18:33:10 +0000 (20:33 +0200)]
PEP 614 support (#1717)

4 years agoFix typo in docstring (#1700)
Daniel [Sun, 13 Sep 2020 15:59:18 +0000 (17:59 +0200)]
Fix typo in docstring (#1700)

Added a missing preposition

4 years agoFix empty line handling when formatting typing stubs (#1646)
Richard Si [Thu, 10 Sep 2020 20:21:37 +0000 (16:21 -0400)]
Fix empty line handling when formatting typing stubs (#1646)

Black used to erroneously remove all empty lines between non-function
code and decorators when formatting typing stubs. Now a single empty
line is enforced.

I chose for putting empty lines around decorated classes that have empty
bodies since removing empty lines around such classes would cause a
formatting issue that seems to be impossible to fix.

For example:

```
class A: ...
@some_decorator
class B: ...
class C: ...
class D: ...

@some_other_decorator
def foo(): -> None: ...
```

It is easy to enforce no empty lines between class A, B, and C.
Just return 0, 0 for a line that is a decorator and precedes an stub
class. Fortunately before this commit, empty lines after that class
would be removed already.

Now let's look at the empty line between class D and function foo. In
this case, there should be an empty line there since it's class code next
to function code. The problem is that when deciding to add X empty lines
before a decorator, you can't tell whether it's before a class or a
function. If the decorator is before a function, then an empty line
is needed, while no empty lines are needed when the decorator is
before a class.

So even though I personally prefer no empty lines around decorated
classes, I had to go the other way surrounding decorated classes with
empty lines.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
4 years agoVirtualenv is now formatted with newest Black https://github.com/pypa/virtualenv...
Hugo van Kemenade [Thu, 10 Sep 2020 19:52:23 +0000 (22:52 +0300)]
Virtualenv is now formatted with newest Black https://github.com/pypa/virtualenv/pull/1939 (#1695)

4 years agoFix unstable subscript assignment string wrapping (#1678)
Bryan Bugyi [Thu, 10 Sep 2020 16:24:01 +0000 (12:24 -0400)]
Fix unstable subscript assignment string wrapping (#1678)

Fixes #1598

4 years agoAdd link to conda-forge integration (#1687)
Michael Wilkinson [Tue, 8 Sep 2020 16:42:57 +0000 (12:42 -0400)]
Add link to conda-forge integration (#1687)

* Add link to conda-forge integration

resolves #1686

* README: keep PyPI tags together

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
4 years agoFix crash on assert and parenthesized % format (fixes #1597, fixes #1605) (#1681)
Bryan Bugyi [Sun, 6 Sep 2020 16:15:40 +0000 (12:15 -0400)]
Fix crash on assert and parenthesized % format (fixes #1597, fixes #1605) (#1681)

4 years agoFix crash on concatenated string + comment (fixes #1596) (#1677)
Bryan Bugyi [Sun, 6 Sep 2020 15:02:57 +0000 (11:02 -0400)]
Fix crash on concatenated string + comment (fixes #1596) (#1677)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
4 years agoFix unstable formatting on string split + % formatting (#1680)
Bryan Bugyi [Sun, 6 Sep 2020 00:24:00 +0000 (20:24 -0400)]
Fix unstable formatting on string split + % formatting (#1680)

Fixes #1595

4 years agoHandle .COLOR_DIFF in the same way as .DIFF (#1673)
Tom Saunders [Sat, 5 Sep 2020 19:15:28 +0000 (20:15 +0100)]
Handle .COLOR_DIFF in the same way as .DIFF (#1673)

4 years agoTest primer on Pillow (#1679)
Hugo van Kemenade [Sat, 5 Sep 2020 16:38:43 +0000 (19:38 +0300)]
Test primer on Pillow (#1679)

4 years agoUpdate primer.json to reflect Black's adoption (#1674)
Richard Si [Fri, 4 Sep 2020 21:20:55 +0000 (17:20 -0400)]
Update primer.json to reflect Black's adoption (#1674)

- tox recently adopted Black
https://github.com/tox-dev/tox/commit/a7903508fa07068b327e15cfdbf8ea330ab78765

- attrs already adopted Black but they updated to 20.08b1 + did a format pass and removed some trailing commas
https://github.com/python-attrs/attrs/commit/f680c5b83e65413eeb684c68ece60198015058c3

4 years agoClarify current trailing comma behavior in the docs
Łukasz Langa [Tue, 1 Sep 2020 11:24:31 +0000 (13:24 +0200)]
Clarify current trailing comma behavior in the docs

4 years agoMention optional invalid W503 warning in pycodestyle
Łukasz Langa [Tue, 1 Sep 2020 11:18:46 +0000 (13:18 +0200)]
Mention optional invalid W503 warning in pycodestyle

4 years agoFix incorrect space before colon in if/while stmts (#1655)
Richard Si [Mon, 31 Aug 2020 21:20:05 +0000 (17:20 -0400)]
Fix incorrect space before colon in if/while stmts (#1655)

* Fix incorrect space before colon in if/while stmts

Previously Black would format this code

```
if (foo := True):
print(foo)
```

as

```
if (foo := True) :
print(foo)
```

adding an incorrect space after the RPAR. Buggy code in the
normalize_invisible_parens function caused the colon to be wrapped in
invisible parentheses. The LPAR of that pair was then prefixed with a
single space at the request of the whitespace function.

This commit fixes the accidental skipping of a pre-condition check
which must return True before parenthesis normalization of a specific
child Leaf or Node can happen. The pre-condition check being skipped
was why the colon was wrapped in invisible parentheses.

* Add an entry in CHANGES.md

4 years agoRemove flake8 W503 from docs as it is ignored by default (#1661)
Jon Dufresne [Mon, 31 Aug 2020 21:18:43 +0000 (14:18 -0700)]
Remove flake8 W503 from docs as it is ignored by default (#1661)

Fixes #1660

4 years agoFix typo in comment (#1650)
Tristan Seligmann [Fri, 28 Aug 2020 15:37:37 +0000 (17:37 +0200)]
Fix typo in comment (#1650)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
4 years agofix 1631 and add test (#1641)
mbarkhau [Thu, 27 Aug 2020 11:47:59 +0000 (11:47 +0000)]
fix 1631 and add test (#1641)

4 years agoFix multiline docstring quote normalization
Richard Si [Wed, 26 Aug 2020 22:17:59 +0000 (18:17 -0400)]
Fix multiline docstring quote normalization

The quotes of multiline docstrings are now only normalized when string
normalization is off, instead of the string normalization setting being
ignored and the quotes being *always* normalized.

I had to make a new test case and data file since the current pair for
docstrings only worked when there is no formatting difference between the
formatting results with string normalization on and off. I needed to add
tests for when there *are* differences between the two. So I split
test_docstring's test code when string normalization is disabled into a
new test case along with a new data file.

4 years agoFix g:black_fast and g:black_(skip)_string_normalization opts
Rowan Rodrik van der Molen [Sat, 11 Jul 2020 19:20:31 +0000 (21:20 +0200)]
Fix g:black_fast and g:black_(skip)_string_normalization opts

4 years ago Revert contains_pragma_comment function changes
Yurii Karabas [Wed, 26 Aug 2020 10:43:00 +0000 (13:43 +0300)]
 Revert contains_pragma_comment function changes

4 years agoRevert contains_standalone_comments function changes
Yurii Karabas [Wed, 26 Aug 2020 06:35:21 +0000 (09:35 +0300)]
Revert contains_standalone_comments function changes

4 years agoSimplify black code by using generator expressions
Yurii Karabas [Tue, 23 Jun 2020 21:33:05 +0000 (00:33 +0300)]
Simplify black code by using generator expressions

4 years agoStop running Primer on macOS as it's flaky on GitHub Actions
Łukasz Langa [Wed, 26 Aug 2020 16:18:14 +0000 (18:18 +0200)]
Stop running Primer on macOS as it's flaky on GitHub Actions

4 years agov20.8b1
Łukasz Langa [Wed, 26 Aug 2020 15:50:44 +0000 (17:50 +0200)]
v20.8b1

4 years agoMake dependency on Click 7.0, regex 2020.1.8, and toml 0.10.1 explicit
Łukasz Langa [Wed, 26 Aug 2020 15:15:20 +0000 (17:15 +0200)]
Make dependency on Click 7.0, regex 2020.1.8, and toml 0.10.1 explicit

4 years agoAdd expected failure tests with the unstable formattings
Łukasz Langa [Wed, 26 Aug 2020 10:57:38 +0000 (12:57 +0200)]
Add expected failure tests with the unstable formattings

4 years agoInclude mode information for unstable formattings
Łukasz Langa [Wed, 26 Aug 2020 10:57:05 +0000 (12:57 +0200)]
Include mode information for unstable formattings

4 years agoTreat all trailing commas as pre-existing, as they effectively are
Łukasz Langa [Wed, 26 Aug 2020 10:22:56 +0000 (12:22 +0200)]
Treat all trailing commas as pre-existing, as they effectively are

On a second pass of Black on the same file, inserted trailing commas are now
pre-existing.  Doesn't make sense to differentiate between the passes then.

4 years agov20.8b0
Łukasz Langa [Wed, 26 Aug 2020 14:00:55 +0000 (16:00 +0200)]
v20.8b0

4 years agoPrimer update config - enable pytest (#1626)
Cooper Lees [Wed, 26 Aug 2020 04:55:05 +0000 (21:55 -0700)]
Primer update config - enable pytest (#1626)

Reformatted projects I have acceess to:
- aioexabgp
- bandersnatch
- flake8-bugbear

```
-- 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
```

* Also re-enable pytest

```
-- primer results 📊 --

14 / 16 succeeded (87.5%) ✅
0 / 16 FAILED (0.0%) 💩
 - 2 projects disabled by config
 - 0 projects skipped due to Python version
 - 0 skipped due to long checkout

real 2m26.207s
user 17m55.404s
sys 0m43.061s
```

4 years agoAdd links regarding Spotless integration for gradle/maven users (#1622)
Ned Twigg [Wed, 26 Aug 2020 01:54:05 +0000 (18:54 -0700)]
Add links regarding Spotless integration for gradle/maven users (#1622)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
4 years agoImprove docstring re-indentation handling
Łukasz Langa [Tue, 25 Aug 2020 20:26:13 +0000 (22:26 +0200)]
Improve docstring re-indentation handling

This addresses a few crashers, namely:

* producing non-equivalent code due to mangling escaped newlines,

* invalid hugging quote characters in the docstring body to the docstring outer
  triple quotes (causing a quadruple quote which is a syntax error),

* lack of handling for docstrings that start on the same line as the `def`, and

* invalid stripping of outer triple quotes when the docstring contained
  a string prefix.

As a bonus, tests now also run when string normalization is disabled.

4 years agoAddress pre-existing trailing commas when not in the rightmost bracket pair
Łukasz Langa [Mon, 24 Aug 2020 16:29:59 +0000 (18:29 +0200)]
Address pre-existing trailing commas when not in the rightmost bracket pair

This required some hackery.  Long story short, we need to reuse the ability to
omit rightmost bracket pairs (which glues them together and splits on something
else instead), for use with pre-existing trailing commas.

This form of user-controlled formatting is brittle so we have to be careful not
to cause a scenario where Black first formats code without trailing commas in
one way, and then looks at the same file with pre-existing trailing commas
(that it itself put on the previous run) and decides to format the code again.

One particular ugly edge case here is handling of optional parentheses.  In
particular, the long-standing `line_length=1` hack got in the way of
pre-existing trailing commas and had to be removed.  Instead, a more
intelligent but costly solution was put in place: a "second opinion" if the
formatting that omits optional parentheses ended up causing lines to be too
long.  Again, for efficiency purposes, Black reuses Leaf objects from blib2to3
and modifies them in place, which was invalid for having two separate
formattings.  Line cloning was used to mitigate this.

Fixes #1619

4 years agoRun trailing comma tests with TargetVersion.PY38
Łukasz Langa [Mon, 24 Aug 2020 19:33:51 +0000 (21:33 +0200)]
Run trailing comma tests with TargetVersion.PY38

4 years agoAdd more trailing comma test variants
Łukasz Langa [Mon, 24 Aug 2020 16:48:11 +0000 (18:48 +0200)]
Add more trailing comma test variants

4 years agoMake doc generation a little smarter, update doc sections
Łukasz Langa [Mon, 24 Aug 2020 12:33:16 +0000 (14:33 +0200)]
Make doc generation a little smarter, update doc sections

4 years agoUpdate the changelog
Łukasz Langa [Mon, 24 Aug 2020 12:11:18 +0000 (14:11 +0200)]
Update the changelog

4 years agoProperty-based fuzz test
Zac-HD [Fri, 21 Aug 2020 10:58:58 +0000 (20:58 +1000)]
Property-based fuzz test

4 years agoFix dealing with generated files in docs
Łukasz Langa [Fri, 21 Aug 2020 13:55:03 +0000 (15:55 +0200)]
Fix dealing with generated files in docs

4 years agoUse properly renamed function name in docs
Łukasz Langa [Fri, 21 Aug 2020 13:46:00 +0000 (15:46 +0200)]
Use properly renamed function name in docs

4 years agoRequire Sphinx 3
Łukasz Langa [Fri, 21 Aug 2020 13:42:58 +0000 (15:42 +0200)]
Require Sphinx 3

4 years agoMark Primer projects that will change formatting
Łukasz Langa [Fri, 21 Aug 2020 13:27:08 +0000 (15:27 +0200)]
Mark Primer projects that will change formatting

4 years agoOpen file explicitly with UTF-8 so it works on Windows, too
Łukasz Langa [Thu, 20 Aug 2020 17:21:40 +0000 (19:21 +0200)]
Open file explicitly with UTF-8 so it works on Windows, too

4 years agoReformat docs/conf.py according to the new style
Łukasz Langa [Thu, 20 Aug 2020 17:04:56 +0000 (19:04 +0200)]
Reformat docs/conf.py according to the new style