Commit Graph

1269 Commits

Author SHA1 Message Date
Laurent Lyaudet
07a2e6f678
Fix typo in file_collection_and_discovery.md (GH-2860)
"you your" -> "your"

Co-authored-by: Felix Hildén <felix.hilden@gmail.com>
2022-02-10 20:32:55 -05:00
Xuan (Sean) Hu
862c6f2c0c
Order the disabled error codes for pylint (GH-2870)
Just make them alphabetical.
2022-02-10 20:31:28 -05:00
Joachim Jablon
b4a6bb08fa
Avoid crashing when the user has no homedir (#2814) 2022-02-08 12:13:58 -08:00
Paolo Melchiorre
9b317178d6
Add Django in 'used by' section in Readme (#2875)
* Add Django in 'used by' section in Readme

* Fix Readme issue
2022-02-08 11:38:39 -08:00
dependabot[bot]
01001d5cff
Bump sphinx-copybutton from 0.4.0 to 0.5.0 in /docs (#2871)
Bumps [sphinx-copybutton](https://github.com/executablebooks/sphinx-copybutton) from 0.4.0 to 0.5.0.
- [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.4.0...v0.5.0)

---
updated-dependencies:
- dependency-name: sphinx-copybutton
  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-02-07 07:31:58 -08:00
Felix Hildén
31fe97e7ce
Create indentation FAQ entry (#2855)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-02-02 08:59:42 +02:00
Peter Mescalchin
111880efc7
Update description for GitHub Action options: argument (GH-2858)
It was missing --diff as one of the default arguments passed.
2022-02-01 22:17:45 -05:00
Richard Si
fb9fe6b565
Isolate command line tests from user-level config (#2851) 2022-01-31 21:29:01 -08:00
S. Co1
f3f3acc444
Surface links to Stability Policy (GH-2848) 2022-01-31 19:06:52 -05:00
Jelle Zijlstra
afc0fb05cb
release process: formalize the changelog template (#2837)
I did this manually for the last few releases and I think it's going to be
helpful in the future too. Unfortunately this adds a little more work during
the release (sorry @cooperlees).

This change will also improve the merge conflict situation a bit, because
changes to different sections won't merge conflict.

For the last release, the sections were in a kind of random order. In the
template I put highlights and "Style" first because they're most important
to users, and alphabetized the rest.
2022-01-30 14:04:06 -08:00
Frédérik Paradis
cae7ae3a4d
Soft comparison of --required-version (#2832)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Felix Hildén <felix.hilden@gmail.com>
2022-01-30 13:42:56 -08:00
Jelle Zijlstra
f61299a62a
Exclude __pypackages__ by default (GH-2836)
PDM uses this as part of not-accepted-yet PEP 582.
2022-01-30 15:01:56 -05:00
Jelle Zijlstra
bbe1bdf1ed
Adjust --preview documentation (#2833) 2022-01-30 21:53:45 +02:00
Richard Si
d038a24ca2
Prepare docs for release 22.1.0 (GH-2826) 2022-01-29 14:30:25 -05:00
Jelle Zijlstra
dea2f94ebd
Fix changelog entries in the wrong release (#2825) 2022-01-29 09:32:52 -08:00
Jelle Zijlstra
c5f8e8bd59
Fix changelog entries in the wrong release (#2825) 2022-01-29 09:32:26 -08:00
Jelle Zijlstra
0d768e58f4
Remove test suite from setup.py (#2824)
We no longer use it
2022-01-29 08:00:59 -08:00
Richard Si
8acb8548c3
Update classifiers to reflect stable (#2823) 2022-01-29 07:37:51 -08:00
Shantanu
a4992b4d50
Add a test case to torture.py (#2822)
Co-authored-by: hauntsaninja <>
2022-01-28 19:38:50 -08:00
Nipunn Koorapati
a24e1f7959
Fix instability due to trailing comma logic (#2572)
It was causing stability issues because the first pass
could cause a "magic trailing comma" to appear, meaning
that the second pass might get a different result. It's
not critical.

Some things format differently (with extra parens)
2022-01-28 18:13:18 -08:00
Shantanu
95e77cb559
Fix arithmetic stability issue (#2817)
It turns out "simple_stmt" isn't that simple: it can contain multiple
statements separated by semicolons. Invisible parenthesis logic for
arithmetic expressions only looked at the first child of simple_stmt.
This causes instability in the presence of semicolons, since the next
run through the statement following the semicolon will be the first
child of another simple_stmt.

I believe this along with #2572 fix the known stability issues.
2022-01-28 16:57:05 -08:00
Felix Hildén
df0aeeeee0
Formalise style preference description (#2818)
Closes #1256: I reworded our style docs to be more explicit about the style we're aiming for and how it is changed (or isn't).
2022-01-28 16:49:43 -08:00
Jelle Zijlstra
4ce049dbfa
torture test (#2815)
Fixes #2651. Fixes #2754. Fixes #2518. Fixes #2321.

This adds a test that lists a number of cases of unstable formatting
that we have seen in the issue tracker. Checking it in will ensure
that we don't regress on these cases.
2022-01-28 16:48:38 -08:00
Shantanu
343795029f
Treat blank lines in stubs the same inside top-level if statements (#2820) 2022-01-28 16:29:07 -08:00
Felix Hildén
e1506769a4
Elaborate on Python support policy (#2819) 2022-01-28 10:58:17 -08:00
Jelle Zijlstra
5f01b872e0
reorganize release notes for 22.1.0 (#2790)
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2022-01-28 06:25:24 -08:00
Shantanu
fda2561f79
Tests for unicode identifiers (#2816) 2022-01-28 10:16:25 +02:00
Shivansh-007
777cae55b6
Use parentheses on method access on float and int literals (#2799)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Felix Hildén <felix.hilden@gmail.com>
2022-01-27 21:31:50 -08:00
Jelle Zijlstra
b92822afee
more trailing comma tests (#2810) 2022-01-26 19:44:39 -08:00
Jelle Zijlstra
b517dfb396
black-primer: stop running it (#2809)
At the moment, it's just a source of spurious CI failures and busywork
updating the configuration file.

Unlike diff-shades, it is run across many different platforms and
Python versions, but that doesn't seem essential. We already run unit
tests across platforms and versions.

I chose to leave the code around for now in case somebody is using it,
but CI will no longer run it.
2022-01-26 17:18:43 -08:00
Jelle Zijlstra
889a8d5dd2
Fix crash on some power hugging cases (#2806)
Found by the fuzzer. Repro case:

	python -m black -c 'importA;()<<0**0#'
2022-01-26 16:47:36 -08:00
Jelle Zijlstra
32dd9ecb2e
properly run ourselves twice (#2807)
The previous run-twice logic only affected the stability checks but not the output. Now, we actually output the twice-formatted code.
2022-01-25 15:58:58 -08:00
Richard Si
6417c99bfd
Hug power operators if its operands are "simple" (#2726)
Since power operators almost always have the highest binding power in expressions, it's often more readable to hug it with its operands. The main exception to this is when its operands are non-trivial in which case the power operator will not hug, the rule for this is the following:

> For power ops, an operand is considered "simple" if it's only a NAME, numeric CONSTANT, or attribute access (chained attribute access is allowed), with or without a preceding unary operator. 

Fixes GH-538.
Closes GH-2095.

diff-shades results: https://gist.github.com/ichard26/ca6c6ad4bd1de5152d95418c8645354b

Co-authored-by: Diego <dpalma@evernote.com>
Co-authored-by: Felix Hildén <felix.hilden@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-01-24 19:13:34 -08:00
Felix Hildén
73cb6e7734
Make SRC or code mandatory and mutually exclusive (#2360) (#2804)
Closes #2360: I'd like to make passing SRC or `--code` mandatory and the arguments mutually exclusive. This will change our (partially already broken) promises of CLI behavior, but I'll comment below.
2022-01-24 07:35:56 -08:00
Nikita Sobolev
3905173cb3
Use magic_trailing_comma and preview for FileMode in fuzz (#2802)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-01-23 12:34:29 -08:00
Cooper Lees
d2c938eb02
Remove Beta mentions in README + Docs (#2801)
- State we're now stable and that we'll uphold our formatting changes as per policy
- Link to The Black Style doc.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-01-23 12:34:01 -08:00
Richard Si
6e3677f3f0
Allow blackd to be run as a package (#2800) 2022-01-23 08:49:11 -08:00
Batuhan Taskaya
022f89625f
Enable pattern matching by default (#2758)
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2022-01-22 12:05:26 -08:00
Shantanu
b3b341b44f
Mention "skip news" label in CHANGELOG action (#2797)
Co-authored-by: hauntsaninja <>
2022-01-22 07:30:18 -08:00
Shantanu
811de5f36b
Refactor logic for stub empty lines (#2796)
This PR is intended to have no change to semantics.

This is in preparation for #2784 which will likely introduce more logic
that depends on `current_line.depth`.

Inlining the subtraction gets rid of offsetting and makes it much easier
to see what the result will be.
2022-01-22 07:29:38 -08:00
Richard Si
fb1d1b2fc8
Mark Felix and Batuhan as maintainers (#2794)
Y'all deserve it :)
2022-01-22 14:08:27 +03:00
Perry Vargas
10677baa40
Allow setting custom cache directory on all platforms (#2739)
Fixes #2506

``XDG_CACHE_HOME`` does not work on Windows. To allow for users to set a custom cache directory on all systems I added a new environment variable ``BLACK_CACHE_DIR`` to set the cache directory. The default remains the same so users will only notice a change if that environment variable is set.

The specific use case I have for this is I need to run black on in different processes at the same time. There is a race condition with the cache pickle file that made this rather difficult. A custom cache directory will remove the race condition.

I created ``get_cache_dir`` function in order to test the logic. This is only used to set the ``CACHE_DIR`` constant.
2022-01-21 22:00:33 -08:00
Richard Si
d24bc4364c
Switch to Furo (#2793)
- Add Furo dependency to docs/requirements.txt
- Drop a fair bit of theme configuration
- Fix the toctree declarations in index.rst
- Move stuff around as Furo isn't 100% compatible with Alabaster

Furo was chosen as it provides excellent mobile support, user
controllable light/dark theming, and is overall easier to read
2022-01-21 15:00:13 -08:00
Rob Hammond
95c03b9638
add wind technology software projects using black (#2792) 2022-01-21 10:23:26 -08:00
Shivansh-007
e0c572833a
Set click lower bound to 8.0.0 (#2791)
Closes #2774
2022-01-21 08:54:57 -08:00
Michael Marino
4ea75cd495
Add support for custom python cell magics (#2744)
Fixes #2742.

This PR adds the ability to configure additional python cell magics. This
will allow formatting cells in Jupyter Notebooks that are using custom (python)
magics.
2022-01-20 16:45:28 -08:00
emfdavid
e66e0f8ff0
Hint at likely cause of ast parsing failure in error message (#2786)
Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2022-01-20 15:48:49 -08:00
Felix Hildén
6e97c5f47c
Deprecate ESP and move the functionality under --preview (#2789) 2022-01-20 15:42:07 -08:00
Richard Si
9bd4134f31
Fix and speedup diff-shades integration (#2773) 2022-01-19 19:05:58 -08:00
Felix Hildén
8c22d232b5
Create --preview CLI flag (#2752) 2022-01-19 17:34:52 -08:00