]> 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
23 months agoAdd email for Richard Si (#3478)
Richard Si [Mon, 2 Jan 2023 14:43:48 +0000 (09:43 -0500)]
Add email for Richard Si (#3478)

23 months agoFail lint CI if the PR doesn't target main (#3477)
Richard Si [Sat, 31 Dec 2022 06:52:35 +0000 (01:52 -0500)]
Fail lint CI if the PR doesn't target main (#3477)

Let's skip the check if we're running on a fork just in case someone
opens a PR against a branch on said fork as part of a PR review
upstream.

23 months agoParenthesize conditional expressions (#2278)
Jordan Ephron [Thu, 29 Dec 2022 23:13:15 +0000 (18:13 -0500)]
Parenthesize conditional expressions (#2278)

Co-authored-by: Jordan Ephron <JEphron@users.noreply.github.com>
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
23 months agoBump peter-evans/find-comment from 2.1.0 to 2.2.0 (#3476)
dependabot[bot] [Thu, 29 Dec 2022 22:00:23 +0000 (14:00 -0800)]
Bump peter-evans/find-comment from 2.1.0 to 2.2.0 (#3476)

Bumps [peter-evans/find-comment](https://github.com/peter-evans/find-comment) from 2.1.0 to 2.2.0.
- [Release notes](https://github.com/peter-evans/find-comment/releases)
- [Commits](https://github.com/peter-evans/find-comment/compare/f4499a714d59013c74a08789b48abe4b704364a0...81e2da3af01c92f83cb927cf3ace0e085617c556)

---
updated-dependencies:
- dependency-name: peter-evans/find-comment
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
23 months agoBump pypa/cibuildwheel from 2.11.3 to 2.11.4 (#3475)
dependabot[bot] [Mon, 26 Dec 2022 14:32:42 +0000 (06:32 -0800)]
Bump pypa/cibuildwheel from 2.11.3 to 2.11.4 (#3475)

Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.11.3 to 2.11.4.
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](https://github.com/pypa/cibuildwheel/compare/v2.11.3...v2.11.4)

---
updated-dependencies:
- dependency-name: pypa/cibuildwheel
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
23 months agoFix some typos (#3474)
Semen Zhydenko [Mon, 26 Dec 2022 02:39:51 +0000 (03:39 +0100)]
Fix some typos (#3474)

23 months agoSignificantly speedup ESP on large expressions that contain many strings (#3467)
Yilei "Dolee" Yang [Fri, 23 Dec 2022 20:13:45 +0000 (12:13 -0800)]
Significantly speedup ESP on large expressions that contain many strings (#3467)

23 months agoAdd latest_prerelease Docker Hub tag for following the latest alpha release (#3465)
Matthew Armand [Wed, 21 Dec 2022 03:18:15 +0000 (22:18 -0500)]
Add latest_prerelease Docker Hub tag for following the latest alpha release (#3465)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
23 months agoFix an issue where extra empty lines are added. (#3470)
Yilei "Dolee" Yang [Wed, 21 Dec 2022 01:58:02 +0000 (17:58 -0800)]
Fix an issue where extra empty lines are added. (#3470)

23 months agoVim plugin docs improvements (#3468)
Matthew Armand [Tue, 20 Dec 2022 23:00:06 +0000 (18:00 -0500)]
Vim plugin docs improvements (#3468)

* Organize vim plugin section with headers to separate out Installation, Usage, and Troubleshooting for readability and easy linking

* Add missing plugin configuration options, with current defaults

* Add installation note for Arch Linux, now that the plugin is shipped with the python-black package (ref: https://bugs.archlinux.org/task/73024)

* Fix vim-plug specification to follow stable releases. Moving the same tag is an antipattern that doesn't re-resolve with vim-plug, see this discussion for more detail (https://github.com/junegunn/vim-plug/pull/720\#issuecomment-1105829356). Per vim-plug's maintainer's recommendation, use the 'tag' key instead with a shell wildcard. Wildcard should be '*.*.*' as that follows Black's versioning detailed here (https://black.readthedocs.io/en/latest/contributing/release_process.html\#cutting-a-release) and doesn't include current alpha releases.

23 months agoFix a crash in ESP where a standalone comment is placed before a dict's value (#3469)
Yilei "Dolee" Yang [Tue, 20 Dec 2022 22:59:38 +0000 (14:59 -0800)]
Fix a crash in ESP where a standalone comment is placed before a dict's value (#3469)

23 months agoExclude string type annotations from ESP (#3462)
Yilei "Dolee" Yang [Tue, 20 Dec 2022 21:38:35 +0000 (13:38 -0800)]
Exclude string type annotations from ESP (#3462)

23 months agoFix an f-string crash in ESP. (#3463)
Yilei "Dolee" Yang [Tue, 20 Dec 2022 14:36:42 +0000 (06:36 -0800)]
Fix an f-string crash in ESP. (#3463)

23 months agoDo not move docker `latest_release` tag for Pre-Releases (#3461)
Cooper Lees [Tue, 20 Dec 2022 02:08:13 +0000 (18:08 -0800)]
Do not move docker `latest_release` tag for Pre-Releases (#3461)

* Do not move docker `latest_release` tag for Pre-Releases

- When we do a pre-release lets not move the latest_release tag
  - This tag should only move on official real releases

Fixes #3453

* Make it prettier - TIL we format our yaml

2 years agotomli: Don't worry about specific alpha releases (#3448)
Jelle Zijlstra [Sun, 18 Dec 2022 03:02:01 +0000 (19:02 -0800)]
tomli: Don't worry about specific alpha releases (#3448)

This prevents bugs due to pypa/packaging#522.

Fixes #3447.

2 years agoFix syntax error in match test (#3426)
Jelle Zijlstra [Sat, 17 Dec 2022 22:51:10 +0000 (14:51 -0800)]
Fix syntax error in match test (#3426)

2 years agoCheck stability for both preview and non-preview styles (#3423)
Jelle Zijlstra [Sat, 17 Dec 2022 18:31:47 +0000 (10:31 -0800)]
Check stability for both preview and non-preview styles (#3423)

And fix parens-related test failures this found.

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agoRemove separate 3.11 CI now deps support 3.11 (#3446)
Cooper Lees [Sat, 17 Dec 2022 17:19:45 +0000 (09:19 -0800)]
Remove separate 3.11 CI now deps support 3.11 (#3446)

* Remove separate 3.11 CI now deps support 3.11

- We can run everything now like all other stable versions of Python
- test in a 3.11 vent: `/tmp/tb/bin/tox -e py311,ci-py311`

```
  py311: OK (28.99=setup[7.90]+cmd[5.29,0.66,6.94,6.08,1.89,0.24] seconds)
  ci-py311: OK (30.33=setup[3.20]+cmd[3.66,0.31,17.43,4.60,0.90,0.23] seconds)
  congratulations :) (59.35 seconds)
```

* Add to CHANGES.md

* Add fuzz run in 3.11

2 years agoFix an infinite recursion error exposed by #3440 (#3444)
Yilei "Dolee" Yang [Fri, 16 Dec 2022 13:02:41 +0000 (05:02 -0800)]
Fix an infinite recursion error exposed by #3440 (#3444)

2 years agoPrefer splitting right hand side of assignment statements. (#3368)
Yilei "Dolee" Yang [Thu, 15 Dec 2022 23:58:51 +0000 (15:58 -0800)]
Prefer splitting right hand side of assignment statements. (#3368)

2 years agoImprove long values in dict literals (#3440)
Yilei "Dolee" Yang [Thu, 15 Dec 2022 16:25:28 +0000 (08:25 -0800)]
Improve long values in dict literals (#3440)

2 years agoFix a crash when a colon line is marked between `# fmt: off` and `# fmt: on` (#3439)
Yilei "Dolee" Yang [Thu, 15 Dec 2022 01:56:14 +0000 (17:56 -0800)]
Fix a crash when a colon line is marked between `# fmt: off` and `# fmt: on` (#3439)

2 years agoDo not put the closing quotes in a docstring on a separate line (#3430)
Jelle Zijlstra [Tue, 13 Dec 2022 04:56:38 +0000 (20:56 -0800)]
Do not put the closing quotes in a docstring on a separate line (#3430)

Fixes #3320. Followup from #3044.

2 years agoBump furo from 2022.9.29 to 2022.12.7 in /docs (#3433)
dependabot[bot] [Mon, 12 Dec 2022 14:28:12 +0000 (06:28 -0800)]
Bump furo from 2022.9.29 to 2022.12.7 in /docs (#3433)

Bumps [furo](https://github.com/pradyunsg/furo) from 2022.9.29 to 2022.12.7.
- [Release notes](https://github.com/pradyunsg/furo/releases)
- [Changelog](https://github.com/pradyunsg/furo/blob/main/docs/changelog.md)
- [Commits](https://github.com/pradyunsg/furo/compare/2022.09.29...2022.12.07)

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

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoBump pypa/cibuildwheel from 2.11.2 to 2.11.3 (#3434)
dependabot[bot] [Mon, 12 Dec 2022 14:27:18 +0000 (06:27 -0800)]
Bump pypa/cibuildwheel from 2.11.2 to 2.11.3 (#3434)

Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.11.2 to 2.11.3.
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](https://github.com/pypa/cibuildwheel/compare/v2.11.2...v2.11.3)

---
updated-dependencies:
- dependency-name: pypa/cibuildwheel
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoBump mypy[c] from 0.971 to 0.991 (#3380)
Richard Si [Sat, 10 Dec 2022 20:56:34 +0000 (15:56 -0500)]
Bump mypy[c] from 0.971 to 0.991 (#3380)

2 years agoAdding pyproject.toml configuration output to verbose logging (#3392)
mainj12 [Sat, 10 Dec 2022 20:56:14 +0000 (20:56 +0000)]
Adding pyproject.toml configuration output to verbose logging (#3392)

2 years agomake black[jupyter] installation cross-shell (#3394)
Marco Edward Gorelli [Sat, 10 Dec 2022 19:49:33 +0000 (19:49 +0000)]
make black[jupyter] installation cross-shell (#3394)

2 years agoFix a crash in preview style with assert + parenthesized string. (#3415)
Yilei "Dolee" Yang [Sat, 10 Dec 2022 15:58:45 +0000 (07:58 -0800)]
Fix a crash in preview style with assert + parenthesized string. (#3415)

The bug is in the `get_leaves_inside_matching_brackets` on the third line below:

```python
assert xxxxxxxxx.xxxxxxxxx.xxxxxxxxx(
    xxxxxxxxx
).xxxxxxxxxxxxxxxxxx(), (
    "xxx {xxxxxxxxx} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
)
```

Including the invisible paren, third line is `).xxxxxxxxxxxxxxxxxx()), (`, that it has a matched pair then an unmatched closing paren afterwards. This PR ensures the returned leaves are actually matched.

Fixes #3414.

2 years agoFix type annotation for gitignore pathspec (#3416)
Isac Byeonghoon Yoo [Sat, 10 Dec 2022 15:08:05 +0000 (00:08 +0900)]
Fix type annotation for gitignore pathspec (#3416)

2 years agoPrepare release 22.12.0 (#3413)
Jelle Zijlstra [Fri, 9 Dec 2022 15:49:43 +0000 (07:49 -0800)]
Prepare release 22.12.0 (#3413)

2 years agorelease: skip bad macos wheels for now (#3411)
Jelle Zijlstra [Fri, 9 Dec 2022 04:36:39 +0000 (20:36 -0800)]
release: skip bad macos wheels for now (#3411)

Workaround for #3312

2 years agoBump peter-evans/find-comment from 2.0.1 to 2.1.0 (#3404)
dependabot[bot] [Fri, 9 Dec 2022 04:28:29 +0000 (23:28 -0500)]
Bump peter-evans/find-comment from 2.0.1 to 2.1.0 (#3404)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoFix CI with latest flake8-bugbear (#3412)
Jelle Zijlstra [Fri, 9 Dec 2022 04:11:07 +0000 (20:11 -0800)]
Fix CI with latest flake8-bugbear (#3412)

2 years agoBump sphinx-copybutton from 0.5.0 to 0.5.1 in /docs (#3390)
dependabot[bot] [Mon, 21 Nov 2022 16:24:46 +0000 (08:24 -0800)]
Bump sphinx-copybutton from 0.5.0 to 0.5.1 in /docs (#3390)

Bumps [sphinx-copybutton](https://github.com/executablebooks/sphinx-copybutton) from 0.5.0 to 0.5.1.
- [Release notes](https://github.com/executablebooks/sphinx-copybutton/releases)
- [Changelog](https://github.com/executablebooks/sphinx-copybutton/blob/master/CHANGELOG.md)
- [Commits](https://github.com/executablebooks/sphinx-copybutton/compare/v0.5.0...v0.5.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoWordsmith current_style.md (#3383)
sckarlin [Mon, 14 Nov 2022 15:31:43 +0000 (10:31 -0500)]
Wordsmith current_style.md (#3383)

"realtime" doesn't make sense in this context.

2 years agoRemove whitespaces of whitespace-only files (#3348)
Antonio Ossa-Guerra [Sat, 12 Nov 2022 01:05:36 +0000 (22:05 -0300)]
Remove whitespaces of whitespace-only files (#3348)

Currently, empty and whitespace-only (with or without newlines) are
not modified. In some discussions (issues and pull requests) consensus
was to reformat whitespace-only files to empty or single-character
files, preserving line endings when possible. With that said, this
commit introduces the following behaviors:

* Empty files are left as is
* Whitespace-only files (no newline) reformat into empty files
* Whitespace-only files (1 or more newlines) reformat into a single
newline character

To implement these changes, we moved the initial check at
`format_file_contents` that raises `NothingChanged` if the source
(with no whitespaces) is an empty string. In the case of *.ipynb
files, `format_ipynb_string` checks a similar condition and removed
whitespaces. In the case of Python files, `format_str_once` includes a
check on the output that returns the correct newline character if
possible or an empty string otherwise.

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
2 years agoClarify that Black runs with --safe by default (#3378)
Maximilian Cosmo Sitter [Thu, 10 Nov 2022 15:03:19 +0000 (16:03 +0100)]
Clarify that Black runs with --safe by default (#3378)

2 years agoCorrectly handle trailing commas that are inside a line's leading non-nested parens...
Yilei "Dolee" Yang [Wed, 9 Nov 2022 23:08:51 +0000 (15:08 -0800)]
Correctly handle trailing commas that are inside a line's leading non-nested parens (#3370)

- Fixes #1671
- Fixes #3229

2 years agoCompare each .gitignore found with an appropiate relative path (#3338)
Antonio Ossa-Guerra [Tue, 8 Nov 2022 15:50:04 +0000 (12:50 -0300)]
Compare each .gitignore found with an appropiate relative path (#3338)

* Apply .gitignore files considering their location

When a .gitignore file contains the special rule to ignore every
subfolder content (`*/*`) and the file is located in a subfolder
relative to where the command is executed (root), the rule is
incorrectly applied and ignores every file at the same level of the
.gitignore file.

The reason for this is that the `gitignore` variable accumulates the
rules found in each .gitignore while traversing files and directories
recursively. This makes sense and, in general, works as expected. The
problem is that the gitignore rules are applied using as the relative
path from root to target directory as a reference. This is the cause
of the bug.

The implemented solution keeps track of every .gitignore file found
while traversing the targets and the absolute location of each
.gitignore file. Then, when matching files to the .gitignore rules,
compare each set of rules with the appropiate relative path to the
candidate target file.

To make this possible, we changed the single `gitignore` object with a
dictionary of similar objects, where the corresponding key is the
absolute path to the folder that contains that .gitignore file. This
required changing the signature of the `get_sources` function. Also, we
introduce a `is_ignored` function that compares a file with every set
of rules. Finally, some tests required an update to pass the gitignore
object in the new format.

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
* Test .gitignore with `*/*` is applied correctly

The test contains three cases: 1) when the .gitignore with the special
rule to ignore every subfolder and its contents (*/*) is in the root,
2) when the file is inside a subfolder relative to root (nested), and
3) when the target folder contains the .gitignore and root is a parent
folder of the target. In all of these cases, we compare the files that
are visible by Black with a known list of paths containing the
expected values.

Before the fix introduced in the previous commit, these tests failed
when the .gitignore file was nested (second case). Now, the test is
passed for all cases.

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
* Update CHANGES.md

Add entry about fixed bug and changes introduced: ignore files by
considering the location of each .gitignore file and the relative path
of each target

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
* Small refactor to improve code readability

These changes are small improvements to improve code readability:
rename a variable to a more descriptive name (from `exclude_is_None`
to `using_default_exclude`), use a better syntax to include the type
annotation for `gitignore` variable (from typing comment to
Python-style typing annotation), and replace an if-else block with a
single dictionary definition (in this case, we need to compare keys
instead of values, meaning that the change works)

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
* Make nested function a top-level function

The function to match a given path with every discovered .gitignore
file does not need to be a nested function and can be a top-level
function. The arguments did not change, but the naming of local
variables was improved for readability.

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
2 years agoApply .gitignore correctly in every source entry (#3336)
Antonio Ossa-Guerra [Sat, 5 Nov 2022 05:09:59 +0000 (02:09 -0300)]
Apply .gitignore correctly in every source entry (#3336)

When passing multiple src directories, the root gitignore was only
applied to the first processed source. The reason is that, in the
first source, exclude is `None`, but then the value gets overridden by
`re_compile_maybe_verbose(DEFAULT_EXCLUDES)`, so in the next iteration
where the source is a directory, the condition is not met and sets the
value of `gitignore` to `None`.

To fix this problem, we store a boolean indicating if `exclude` is
`None` and set the value of `exclude` to its default value if that's
the case. This makes sure that the flow enters the correct condition on
following iterations and also keeps the original value if the condition
is not met.

Also, the value of `gitignore` is initialized as `None` and overriden
if necessary. The value of `root_gitignore` is always calculated to
avoid using additional variables (at the small cost of additional
computations).

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
2 years agoUpdate docs to include pycodestyle (#3369)
Gerhard van Andel [Tue, 1 Nov 2022 18:42:48 +0000 (12:42 -0600)]
Update docs to include pycodestyle (#3369)

* Add pycodestyle to using_black_with_other_tools.md

2 years agoBump pypa/cibuildwheel from 2.10.2 to 2.11.2 (#3367)
dependabot[bot] [Mon, 31 Oct 2022 13:50:42 +0000 (06:50 -0700)]
Bump pypa/cibuildwheel from 2.10.2 to 2.11.2 (#3367)

Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.10.2 to 2.11.2.
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](https://github.com/pypa/cibuildwheel/compare/v2.10.2...v2.11.2)

---
updated-dependencies:
- dependency-name: pypa/cibuildwheel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoBump peter-evans/create-or-update-comment from 2.0.1 to 2.1.0 (#3366)
dependabot[bot] [Mon, 31 Oct 2022 13:49:52 +0000 (06:49 -0700)]
Bump peter-evans/create-or-update-comment from 2.0.1 to 2.1.0 (#3366)

Bumps [peter-evans/create-or-update-comment](https://github.com/peter-evans/create-or-update-comment) from 2.0.1 to 2.1.0.
- [Release notes](https://github.com/peter-evans/create-or-update-comment/releases)
- [Commits](https://github.com/peter-evans/create-or-update-comment/compare/2b2c85d0bf1b8a7b4e7e344bd5c71dc4b9196e9f...5adcb0bb0f9fb3f95ef05400558bdb3f329ee808)

---
updated-dependencies:
- dependency-name: peter-evans/create-or-update-comment
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoVim plugin: allow using system black rather than virtualenv (#3309)
Corey Hickey [Thu, 27 Oct 2022 23:55:33 +0000 (16:55 -0700)]
Vim plugin: allow using system black rather than virtualenv (#3309)

Provide a configuration parameter to the Vim plugin which will allow the
plugin to skip setting up a virtualenv. This is useful when there is a
system installation of black (e.g. from a Linux distribution) which the
user prefers to use.

Using a virtualenv remains the default.

- Fixes #3308

2 years agoAdd Archer Aviation to organizations in readme (#3361)
Hongbo Miao [Thu, 27 Oct 2022 21:22:44 +0000 (14:22 -0700)]
Add Archer Aviation to organizations in readme (#3361)

2 years agoWrap concatenated strings used as function args in parens (#3307)
Yilei "Dolee" Yang [Thu, 27 Oct 2022 01:03:10 +0000 (18:03 -0700)]
Wrap concatenated strings used as function args in parens (#3307)

Fixes #3292

2 years agoUpdate README.md (#3284)
Ned Western [Wed, 26 Oct 2022 02:04:31 +0000 (13:04 +1100)]
Update README.md (#3284)

Minor typo

2 years agoExclude pytest-xdist 3.0.2 (#3356)
Jelle Zijlstra [Wed, 26 Oct 2022 02:03:24 +0000 (19:03 -0700)]
Exclude pytest-xdist 3.0.2 (#3356)

We're getting warnings like https://github.com/psf/black/actions/runs/3325521041/jobs/5498291478 and I'm not sure how to fix them. I'll open an issue for a long-term solution, but for now avoid 3.0.2 to unbreak CI.

2 years agoEnforce empty lines before classes/functions with sticky leading comments. (#3302)
Yilei "Dolee" Yang [Wed, 26 Oct 2022 01:03:24 +0000 (18:03 -0700)]
Enforce empty lines before classes/functions with sticky leading comments. (#3302)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2 years agoBump peter-evans/create-or-update-comment from 2.0.0 to 2.0.1 (#3354)
dependabot[bot] [Mon, 24 Oct 2022 18:40:19 +0000 (11:40 -0700)]
Bump peter-evans/create-or-update-comment from 2.0.0 to 2.0.1 (#3354)

Bumps [peter-evans/create-or-update-comment](https://github.com/peter-evans/create-or-update-comment) from 2.0.0 to 2.0.1.
- [Release notes](https://github.com/peter-evans/create-or-update-comment/releases)
- [Commits](https://github.com/peter-evans/create-or-update-comment/compare/c9fcb64660bc90ec1cc535646af190c992007c32...2b2c85d0bf1b8a7b4e7e344bd5c71dc4b9196e9f)

---
updated-dependencies:
- dependency-name: peter-evans/create-or-update-comment
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoBump peter-evans/find-comment from 2.0.0 to 2.0.1 (#3353)
dependabot[bot] [Mon, 24 Oct 2022 16:50:14 +0000 (09:50 -0700)]
Bump peter-evans/find-comment from 2.0.0 to 2.0.1 (#3353)

Bumps [peter-evans/find-comment](https://github.com/peter-evans/find-comment) from 2.0.0 to 2.0.1.
- [Release notes](https://github.com/peter-evans/find-comment/releases)
- [Commits](https://github.com/peter-evans/find-comment/compare/1769778a0c5bd330272d749d12c036d65e70d39d...b657a70ff16d17651703a84bee1cb9ad9d2be2ea)

---
updated-dependencies:
- dependency-name: peter-evans/find-comment
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoBump sphinx from 5.2.3 to 5.3.0 in /docs (#3333)
dependabot[bot] [Tue, 18 Oct 2022 01:12:41 +0000 (21:12 -0400)]
Bump sphinx from 5.2.3 to 5.3.0 in /docs (#3333)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoClarify check argument is needed for github action workflow (#3325)
jlplenio [Sat, 15 Oct 2022 18:44:02 +0000 (20:44 +0200)]
Clarify check argument is needed for github action workflow (#3325)

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agoremove unreachable code (#3328)
nn [Tue, 11 Oct 2022 21:34:37 +0000 (00:34 +0300)]
remove unreachable code (#3328)

fixes #3321

2 years agoFix license metadata to follow PEP 621 (#3326)
Amethyst Reese [Mon, 10 Oct 2022 23:54:49 +0000 (16:54 -0700)]
Fix license metadata to follow PEP 621 (#3326)

2 years agoAdd support for named exprs inside function calls as gen-exps (#3327)
Batuhan Taskaya [Mon, 10 Oct 2022 23:54:09 +0000 (02:54 +0300)]
Add support for named exprs inside function calls as gen-exps (#3327)

2 years agoRemove redundant 3.6 code and bump mypy's python_version to 3.7 (#3313)
Hugo van Kemenade [Fri, 7 Oct 2022 00:37:37 +0000 (17:37 -0700)]
Remove redundant 3.6 code and bump mypy's python_version to 3.7 (#3313)

2 years agoPrepare release 22.10.0 (#3311)
Jelle Zijlstra [Thu, 6 Oct 2022 22:33:51 +0000 (15:33 -0700)]
Prepare release 22.10.0 (#3311)

2 years agoAdd option to skip the first line of source code (#3299)
Antonio Ossa-Guerra [Thu, 6 Oct 2022 22:17:32 +0000 (19:17 -0300)]
Add option to skip the first line of source code (#3299)

* Add option to skip the first line in source file

This commit adds a CLi option to skip the first line in the source
files, just like the Cpython command line allows [1]. By enabling the
flag, using `-x` or `--skip-source-first-line`, the first line is
removed temporarilly while the remaining contents are formatted. The
first line is added back before returning the formatted output.

[1]: https://docs.python.org/dev/using/cmdline.html#cmdoption-x

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
* Add tests for `--skip-source-first-line` option

When the flag is disabled (default), black formats the entire source
file, as in every line. In the other hand, if the flag is enabled, by
using `-x` or `--skip-source-first-line`, the first line is retained
while the rest of the source is formatted and then is added back.

These tests use an empty Python file that contains invalid syntax in
its first line (`invalid_header.py`, at `miscellaneous/`). First,
Black is invoked without enabling the flag which should result in an
exit code different than 0. When the flag is enabled, Black is
expected to return a successful exit code and the header is expected
to be retained (even if its not valid Python syntax).

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
* Support skip source first line option for blackd

The recently added option can be added as an acceptable header for
blackd. The arguments are passed in such a way that using the new
header will activate the skip source first line behaviour as expected

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
* Add skip source first line option to blackd docs

The new option can be passed to blackd as a header. This commit
updates the blackd docs to include the new header.

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
* Update CHANGES.md

Include the new Black option to skip the first line of source code in
the configuration section

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
* Update skip first line test including valid syntax

Including valid Python syntax help us make sure that the file is still
actually valid after skipping the first line of the source file (which
contains invalid Python syntax)

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
* Skip first source line at `format_file_in_place`

Instead of skipping the first source line at `format_file_contents`,
do it before. This allow us to find the correct newline and encoding
on the actual source code (everything that's after the header).

This change is also applied at Blackd: take the header before passing
the source to `format_file_contents` and put the header back once we
get the formatted result.

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
* Test output newlines when skipping first line

When skipping the first line of source code, the reference newline must
be taken from the second line of the file instead of the first one, in
case that the file mixes more than one kind of newline character

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
* Test that Blackd also skips first line correctly

Simliarly to the Black tests, we first compare that Blackd fails when
the first line is invalid Python syntax and then check that the result
is the expected when tha flag is activated

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
* Use the content encoding to decode the header

When decoding the header to put it back at the top of the contents of
the file, use the same encoding used in the content. This should be a
better "guess" that using the default value

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
2 years agoPreserve crlf line endings in blackd (#3257)
KotlinIsland [Tue, 4 Oct 2022 20:10:11 +0000 (06:10 +1000)]
Preserve crlf line endings in blackd (#3257)

Co-authored-by: KotlinIsland <kotlinisland@users.noreply.github.com>
2 years agoBump docutils from 0.18.1 to 0.19 in /docs (#3161)
dependabot[bot] [Mon, 3 Oct 2022 16:36:44 +0000 (09:36 -0700)]
Bump docutils from 0.18.1 to 0.19 in /docs (#3161)

Bumps [docutils](https://docutils.sourceforge.io/) from 0.18.1 to 0.19.

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

Signed-off-by: dependabot[bot] <support@github.com>
2 years agoBump sphinx from 5.2.1 to 5.2.3 in /docs (#3305)
dependabot[bot] [Mon, 3 Oct 2022 07:15:59 +0000 (02:15 -0500)]
Bump sphinx from 5.2.1 to 5.2.3 in /docs (#3305)

Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 5.2.1 to 5.2.3.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/5.x/CHANGES)
- [Commits](https://github.com/sphinx-doc/sphinx/compare/v5.2.1...v5.2.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoBump furo from 2022.9.15 to 2022.9.29 in /docs (#3304)
dependabot[bot] [Mon, 3 Oct 2022 07:08:20 +0000 (02:08 -0500)]
Bump furo from 2022.9.15 to 2022.9.29 in /docs (#3304)

Bumps [furo](https://github.com/pradyunsg/furo) from 2022.9.15 to 2022.9.29.
- [Release notes](https://github.com/pradyunsg/furo/releases)
- [Changelog](https://github.com/pradyunsg/furo/blob/main/docs/changelog.md)
- [Commits](https://github.com/pradyunsg/furo/compare/2022.09.15...2022.09.29)

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

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Cooper Lees <cooper@fb.com>
2 years agoBump myst-parser from 0.18.0 to 0.18.1 in /docs (#3303)
dependabot[bot] [Mon, 3 Oct 2022 07:06:06 +0000 (02:06 -0500)]
Bump myst-parser from 0.18.0 to 0.18.1 in /docs (#3303)

Bumps [myst-parser](https://github.com/executablebooks/MyST-Parser) from 0.18.0 to 0.18.1.
- [Release notes](https://github.com/executablebooks/MyST-Parser/releases)
- [Changelog](https://github.com/executablebooks/MyST-Parser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/executablebooks/MyST-Parser/compare/v0.18.0...v0.18.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoAdd .ipynb_checkpoints to DEFAULT_EXCLUDES (#3293)
Ray Bell [Sun, 2 Oct 2022 16:26:45 +0000 (12:26 -0400)]
Add .ipynb_checkpoints to DEFAULT_EXCLUDES (#3293)

Jupyter creates a checkpoint file every single time you create an .ipynb
file, and then it updates the checkpoint file every single time you
manually save your progress for the initial .ipynb. These checkpoints
are stored in a directory named `.ipynb_checkpoints`.

Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
2 years agoEnable build isolation under CIWB (#3297)
Richard Si [Thu, 29 Sep 2022 02:56:28 +0000 (22:56 -0400)]
Enable build isolation under CIWB (#3297)

No idea how this is still here after the Hatchling PR, but it is no
longer useful and is breaking the build.

2 years agoBump pypa/cibuildwheel from 2.10.0 to 2.10.2 (#3290)
dependabot[bot] [Thu, 29 Sep 2022 02:19:08 +0000 (22:19 -0400)]
Bump pypa/cibuildwheel from 2.10.0 to 2.10.2 (#3290)

updated-dependencies:
- dependency-name: pypa/cibuildwheel
  dependency-type: direct:production
  update-type: version-update:semver-patch

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoMention CHANGES.md in PR template explicitly (#3295)
Ray Bell [Thu, 29 Sep 2022 01:44:16 +0000 (21:44 -0400)]
Mention CHANGES.md in PR template explicitly (#3295)

This makes the location more explicit which hopefully makes the PR
process smoother for other first time contributors.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2 years agoAdd option to format Jupyter Notebooks in GitHub Action (#3282)
Antonio Ossa-Guerra [Mon, 26 Sep 2022 21:45:34 +0000 (18:45 -0300)]
Add option to format Jupyter Notebooks in GitHub Action (#3282)

To run the formatter on Jupyter Notebooks, Black must be installed
with an extra dependency (`black[jupyter]`). This commit adds an
optional argument to install Black with this dependency when using the
official GitHub Action [1]. To enable the formatter on Jupyter
Notebooks, just add `jupyter: true` as an argument. Feature requested
at [2].

[1]: https://black.readthedocs.io/en/stable/integrations/github_actions.html
[2]: https://github.com/psf/black/issues/3280

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
2 years agoBump sphinx from 5.1.1 to 5.2.1 in /docs (#3288)
dependabot[bot] [Mon, 26 Sep 2022 16:48:50 +0000 (09:48 -0700)]
Bump sphinx from 5.1.1 to 5.2.1 in /docs (#3288)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoBump actions/upload-artifact from 2 to 3 (#3289)
dependabot[bot] [Mon, 26 Sep 2022 12:35:23 +0000 (08:35 -0400)]
Bump actions/upload-artifact from 2 to 3 (#3289)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoAlways call freeze_support() if sys.frozen is True (#3275)
Richard Si [Mon, 26 Sep 2022 00:55:52 +0000 (20:55 -0400)]
Always call freeze_support() if sys.frozen is True (#3275)

2 years agoFix outdated references to 3.6 and run pyupgrade (#3286)
Richard Si [Mon, 26 Sep 2022 00:24:18 +0000 (20:24 -0400)]
Fix outdated references to 3.6 and run pyupgrade (#3286)

I also missed the accidental removal of the 3.11 classifier in the PR.

2 years agoSwitch build backend to Hatchling (#3233)
Ofek Lev [Sun, 25 Sep 2022 21:54:33 +0000 (14:54 -0700)]
Switch build backend to Hatchling (#3233)

This implements PEP 621, obviating the need for `setup.py`, `setup.cfg`,
and `MANIFEST.in`. The build backend Hatchling (of which I am a
maintainer in the PyPA) is now used as that is the default in the
official Python packaging tutorial. Hatchling is available on all the
major distribution channels such as Debian, Fedora, and many more.

## Python support

The earliest supported Python 3 version of Hatchling is 3.7, therefore
I've also set that as the minimum here. Python 3.6 is EOL and other
build backends like flit-core and setuptools also dropped support.
Python 3.6 accounted for 3-4% of downloads in the last month.

## Plugins

Configuration is now completely static with the help of 3 plugins:

### Readme

hynek's hatch-fancy-pypi-readme allows for the dynamic construction of
the readme which was previously coded up in `setup.py`. Now it's simply:

```toml
[tool.hatch.metadata.hooks.fancy-pypi-readme]
content-type = "text/markdown"
fragments = [
  { path = "README.md" },
  { path = "CHANGES.md" },
]
```

### Versioning

hatch-vcs is currently just a wrapper around setuptools-scm (which
despite the legacy naming is actually now decoupled from setuptools):

```toml
[tool.hatch.version]
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "src/_black_version.py"
template = '''
version = "{version}"
'''
```

### mypyc

hatch-mypyc offers many benefits over the existing approach:

- No need to manually select files for inclusion
- Avoids the need for the current CI workaround for https://github.com/mypyc/mypyc/issues/946
- Intermediate artifacts (like `build/`) from setuptools and mypyc
  itself no longer clutter the project directory
- Runtime dependencies required at build time no longer need to be
  manually redeclared as this is a built-in option of Hatchling

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2 years agoMake README logo link to docs (#3285)
Stijn de Gooijer [Sun, 25 Sep 2022 09:28:43 +0000 (11:28 +0200)]
Make README logo link to docs (#3285)

docs: Make README logo link to docs

2 years agoFix a crash when `# fmt: on` is used on a different block level than `# fmt: off...
Yilei "Dolee" Yang [Sat, 24 Sep 2022 03:37:22 +0000 (20:37 -0700)]
Fix a crash when `# fmt: on` is used on a different block level than `# fmt: off` (#3281)

Previously _Black_ produces invalid code because the `# fmt: on` is used on a different block level.

While _Black_ requires `# fmt: off` and `# fmt: on` to be used at the same block level, incorrect usage shouldn't cause crashes.

The formatting behavior this PR introduces is, the code below the initial `# fmt: off` block level will be turned off for formatting, when `# fmt: on` is used on a different level or there is no `# fmt: on`. This also matches the current behavior when `# fmt: off` is used at the top-level without a matching `# fmt: on`, it turns off formatting for everything below `# fmt: off`.

- Fixes #2567
- Fixes #3184
- Fixes #2985
- Fixes #2882
- Fixes #2232
- Fixes #2140
- Fixes #1817
- Fixes #569

2 years agoSupport version specifiers in GH action (#3265)
Jakub Kuczys [Fri, 23 Sep 2022 03:23:35 +0000 (05:23 +0200)]
Support version specifiers in GH action (#3265)

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agoMake context manager examples in future style docs consistent (#3274)
Blandes22 [Fri, 23 Sep 2022 03:19:31 +0000 (22:19 -0500)]
Make context manager examples in future style docs consistent (#3274)

2 years agoBuild mypyc wheels for CPython 3.11 (#3276)
Richard Si [Fri, 23 Sep 2022 03:11:56 +0000 (23:11 -0400)]
Build mypyc wheels for CPython 3.11 (#3276)

Bumps cibuildwheel from 2.8.1 to 2.10.0 which has 3.11 building enabled
by default. Unfortunately mypyc errors out on 3.11:

src/black/files.py:29:9: error: Name "tomllib" already defined (by an import)  [no-redef]

... so we have to also hide the fallback import of tomli on older 3.11
alphas from mypy[c].

2 years agoBump furo from 2022.6.21 to 2022.9.15 in /docs (#3277)
dependabot[bot] [Mon, 19 Sep 2022 23:35:46 +0000 (19:35 -0400)]
Bump furo from 2022.6.21 to 2022.9.15 in /docs (#3277)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoFix mypyc build errors on newer manylinux2014_x86_64 images (#3272)
Zsolt Dollenstein [Thu, 15 Sep 2022 20:08:26 +0000 (21:08 +0100)]
Fix mypyc build errors on newer manylinux2014_x86_64 images (#3272)

Make sure `gcc` is installed in the build env

The mypyc build requires `gcc` to be installed even if it's being built with `clang`, otherwise `clang` fails to find `libgcc`.

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

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

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

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

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

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

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

* Move 311 tests to install aiohttp without C extensions

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

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

* Fix formatting + linting

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

* Remove unnecessary warning ignore

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Fixes GH-3207.

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

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