Commit Graph

1391 Commits

Author SHA1 Message Date
Yilei "Dolee" Yang
21218b666a
Fix a string merging/split issue caused by standalone comments. (#3227)
Fixes #2734: a standalone comment causes strings to be merged into one far too long (and requiring two passes to do so).

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2022-08-22 20:40:38 -07:00
Cooper Lees
59acf8af38
Add passing 3.11 CI by exempting blackd tests (#3234)
- Had to exempt blackd tests for now due to aiohttp
  - Skip by using `sys.version_info` tuple
  - aiohttp does not compile in 3.11 yet - refer to #3230
- Add a deadsnakes ubuntu workflow to run 3.11-dev to ensure we don't regress
  - Have it also format ourselves

Test:
- `tox -e 311`

Co-authored-by: Cooper Ry Lees <me@wcooperlees.com>
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2022-08-22 20:39:48 -07:00
Alexander Huynh
6e0ad52e7a
Update email (#3235)
This file gets scraped a lot, so create a distinct email for potential
spam.
2022-08-20 10:45:20 -07:00
Shantanu
4ebf14d17e
Strip trailing commas in subscripts with -C (#3209)
Fixes #2296, #3204
2022-08-13 06:41:34 -07:00
Richard Si
e7b967132f
Port & upstream mypyc wheel build workflow (#3197) 2022-08-12 20:33:17 -07:00
Alexandr Artemyev
07b68e2425
add preview option support for blackd (#3217)
Fixes #3195

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2022-08-12 20:23:02 -07:00
Shantanu
680cbe3a4f
Use --no-implicit-optional for type checking (#3220)
This makes type checking PEP 484 compliant (as of 2018).
mypy will change its defaults soon.

See:
https://github.com/python/mypy/issues/9091
https://github.com/python/mypy/pull/13401
2022-08-12 19:28:47 -07:00
Shantanu
6064a43545
Use debug f-strings for feature detection (#3215)
Fixes GH-2907.
2022-08-10 17:29:47 -04:00
Tom Fryers
507234c47d
Remove invalid syntax in docstrings -S --preview test (#3205)
uR is not a legal string prefix, so this test breaks (AssertionError:
cannot use --safe with this file; failed to parse source file AST:
invalid syntax) if changed to one in which the file is changed. I've
changed the last test to have u alone, and added an R to the test above
instead.
2022-08-02 17:22:04 -04:00
Nicolò Intrieri
f066e3fcae
makes install available for all users in docker image (#3202)
* makes install available for all users in docker image

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

* adds changelog entry for docker-image fix

A changelog entry has been added under the Integration
subheader

* changes dockerfile to use the venv activate script

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

Co-authored-by: Nicolò <nicolo.intrieri@spinforward.it>
Co-authored-by: Cooper Lees <me@cooperlees.com>
2022-08-02 09:01:15 -07:00
dependabot[bot]
b776bf92ad
Bump sphinx from 5.1.0 to 5.1.1 in /docs (#3201)
Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 5.1.0 to 5.1.1.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/5.x/CHANGES)
- [Commits](https://github.com/sphinx-doc/sphinx/compare/v5.1.0...v5.1.1)

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

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-01 13:51:46 -04:00
Richard Si
ca0dbb8fa6
Move fuzz.py to scripts/ (#3199) 2022-07-31 07:34:29 -07:00
Richard Si
eaa048925e
Add sanity check to executable CD + more (#3190)
Building executables without any testing is quite sketchy, let's at
least verify they won't crash on startup and format Black's own
codebase.

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

Finally, I added colorama so all Windows users can get colour.
2022-07-29 20:38:39 -07:00
Richard Si
d85cf00ee8
Remove blib2to3 grammar cache logging (#3193)
As error logs are emitted often (they happen when Black's cache
directory is created after blib2to3 tries to write its cache) and cause
issues to be filed by users who think Black isn't working correctly.

These errors are expected for now and aren't a cause for concern so
let's remove them to stop worrying users (and new issues from being
opened). We can improve the blib2to3 caching mechanism to write its
cache at the end of a successful command line invocation later.
2022-07-29 20:28:43 -07:00
Théophile Bastian
4f1772e2ae
Vim plugin: prefix messages with "Black: " (#3194)
As mentioned in GH-3185, when using Black as a Vim plugin, especially
automatically on save, the plugin's messages can be confusing, as
nothing indicates that they come from Black.
2022-07-28 19:49:00 -04:00
Richard Si
ef8deb6d4a
Consolidate test CI and add concurrency limits (#3189) 2022-07-28 16:55:36 -04:00
Richard Si
411ed778d5
Bump pre-commit hooks (#3191) 2022-07-27 22:04:14 -04:00
Richard Si
44d5da00b5 Reformat codebase with isort 2022-07-27 17:19:28 -04:00
Richard Si
e0a780a505 Add isort to linting toolchain
Co-authored-by: Shivansh-007 <shivansh-007@outlook.com>
2022-07-27 17:19:28 -04:00
dependabot[bot]
e9e756da7a
Bump sphinx from 5.0.2 to 5.1.0 in /docs (#3183)
Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 5.0.2 to 5.1.0.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/5.x/CHANGES)
- [Commits](https://github.com/sphinx-doc/sphinx/compare/v5.0.2...v5.1.0)

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

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-26 20:51:32 -04:00
Yilei "Dolee" Yang
b4dc40bf7a
Use underscores instead of a space in a test file's name (#3180)
... for *consistency*
2022-07-19 21:33:00 -04:00
Yilei "Dolee" Yang
249c6536c4
Fix an infinite loop when using # fmt: on/off ... (#3158)
... in the middle of an expression or code block by adding a missing return.

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-07-19 20:57:23 -04:00
Yilei "Dolee" Yang
6ea4eddf93
Fix the handling of # fmt: skip when it's at a colon line (#3148)
When the Leaf node with `# fmt: skip` is a NEWLINE inside a `suite`
Node, the nodes to ignore should be from the siblings of the parent
`suite` Node.

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

This fixes GH-2646, GH-3126, GH-2680, GH-2421, GH-2339, and GH-2138.
2022-07-19 17:26:11 -04:00
Thomas Grainger
1b6de7b0a3
Improve warning filtering in tests (#3175) 2022-07-18 19:17:13 -07:00
Thomas Grainger
33f0d9e79a
Add pypy-3.8 to test matrix (#3174) 2022-07-16 21:55:46 -04:00
Thomas Grainger
df5a87d93b
configure strict pytest and filterwarnings=['error', ... (#3173)
* configure strict pytest

* ignore current warnings
2022-07-16 13:18:55 +01:00
onescriptkid
b0eed7c6bd
Fix typo in config docs for --extend-exclude (#3170)
The old regex in the example was invalid and caused an error on startup.
2022-07-14 19:51:18 -04:00
Richard Si
ad5c315dda
Actually disable docstring prefix normalization with -S + fix instability (#3168)
The former was a regression I introduced a long time ago. To avoid
changing the stable style too much, the regression is only fixed if
--preview is enabled

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

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

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

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

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

         """
         pass

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-07-14 19:47:33 -04:00
Cooper Lees
9aa33f467b
Move to explicitly creating a new loop (#3164)
* Move to explicitly creating a new loop

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

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

Fixes #3110

* Add to CHANGES.md

* Fix a cooper typo yet again

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

* Update CHANGES.md

Fix my silly typo.

Co-authored-by: Thomas Grainger <tagrain@gmail.com>

Co-authored-by: Cooper Ry Lees <me@wcooperlees.com>
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
2022-07-14 15:24:34 -07:00
Nimrod
8900e3ac8a
Add warning to not run blackd publicly in docs (#3167)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-07-14 15:22:29 -04:00
Richard Si
4f0532d6f0
Don't (ever) put a single-char closing docstring quote on a new line (#3166)
Doing so is invalid. Note this only fixes the preview style since the
logic putting closing docstring quotes on their own line if they violate
the line length limit is quite new.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-07-13 22:26:05 -04:00
Richard Si
18c17bea75
Copy over comments when hugging power ops (#2874)
Otherwise they'd be deleted which was a regression in 22.1.0 (oops! my
bad!). Also type comments are now tracked in the AST safety check on all
compatible platforms to error out if this happens again.

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

Fixes #2873
2022-07-13 17:02:51 -07:00
Maciej Olko
05b63c4bcc
Recommend using BlackConnect in IntelliJ IDEs (#3150)
* Recommend using BlackConnect in IntelliJ IDEs

* IntelliJ IDEs integration docs: improve formatting

* Add changelog for recommending BlackConnect

* IntelliJ IDEs integration docs: improve formatting

* Apply suggestions from code review

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

* Fix indentation

* Apply italic to Black name

Consequently with other places in the document

* Move CHANGELOG entry to Unreleased section

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

* IntelliJ IDEs integration docs: fix extra whitespace and linebreak

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2022-07-11 09:27:51 -07:00
Jelle Zijlstra
7af77d1cf1
Stability policy: permit exceptional changes for unformatted code (#3155) 2022-07-06 13:33:07 -04:00
Jakub Kuczys
b859a377c0
Use RTD's new build process and config (#3149)
See the deprecation notice:
https://docs.readthedocs.io/en/stable/config-file/v2.html#python-version
2022-07-03 16:47:18 -04:00
Dimitri Merejkowsky
6debce63bc
Fix typo in CHANGES.md (#3142) 2022-06-28 10:44:55 +03:00
Richard Si
f6c139c521
Prepare docs for release 22.6.0 (#3139) 2022-06-27 20:33:35 -04:00
Felix Hildén
eb5d175c9c
Update preview style docs to include recent changes (#3136)
Covers GH-2926, GH-2990, GH-2991, and GH-3035.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2022-06-27 16:24:34 -04:00
dependabot[bot]
d848209d38
Bump furo from 2022.6.4.1 to 2022.6.21 in /docs (#3138)
Bumps [furo](https://github.com/pradyunsg/furo) from 2022.6.4.1 to 2022.6.21.
- [Release notes](https://github.com/pradyunsg/furo/releases)
- [Changelog](https://github.com/pradyunsg/furo/blob/main/docs/changelog.md)
- [Commits](https://github.com/pradyunsg/furo/compare/2022.06.04.1...2022.06.21)

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

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-27 09:54:49 -04:00
Yilei "Dolee" Yang
fa6caa6ca8
Only call get_future_imports when needed (#3135) 2022-06-23 12:41:05 -07:00
dependabot[bot]
6463fb874f
Bump sphinx from 5.0.1 to 5.0.2 in /docs (#3128)
Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 5.0.1 to 5.0.2.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/5.x/CHANGES)
- [Commits](https://github.com/sphinx-doc/sphinx/compare/v5.0.1...v5.0.2)

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

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-20 10:22:24 -04:00
Nate Prewitt
e3c9b0430e
Replace link to Requests documentation (#3125) 2022-06-17 12:37:33 -07:00
Sagi Shadur
6c1bd08f16
Test run black on self (#3114)
* Add run_self environment in tox

* Add run_self task as part of the lint CI flow

* Remove hard coded sources list

* Remove black from pre-commit

Co-authored-by: Cooper Lees <me@cooperlees.com>
2022-06-14 09:08:36 -07:00
Hugo van Kemenade
799adb5323
Bump actions/setup-python from 3 to 4 (#3121)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v3...v4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-13 07:02:39 -07:00
Marco Edward Gorelli
162ecd1d2c
Use is_number_token instead of assertion (#3069) 2022-06-11 12:04:09 -04:00
Richard Si
8c8675c62a
Update documentation dependencies (#3118)
Furo, myst-parser, and Sphinx (had to pin docutils due to sphinx breakage)
2022-06-11 11:44:01 -04:00
Sagi Shadur
4bb7bf2bdc
Remove newline after code block open (#3035)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-06-11 09:55:01 +03:00
dependabot[bot]
6d32ab02c5
Bump pre-commit/action from 2.0.3 to 3.0.0 (#3108)
Bumps [pre-commit/action](https://github.com/pre-commit/action) from 2.0.3 to 3.0.0.
- [Release notes](https://github.com/pre-commit/action/releases)
- [Commits](https://github.com/pre-commit/action/compare/v2.0.3...v3.0.0)

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

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-10 20:29:32 -04:00
Vivek Vashist
f51e53726b
Fix minor typo (#3096) 2022-06-03 15:59:26 -07:00
Holger Brunn
436e12f290
Add script to ease migration to black (#3038)
* Add script to ease migration to black

* Update CHANGES.md

Co-authored-by: Cooper Lees <me@cooperlees.com>
2022-06-01 11:20:02 -07:00