Commit Graph

1237 Commits

Author SHA1 Message Date
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
Jelle Zijlstra
98db4abc21
Fix typo in diff_shades.yml workflow (#2778) 2022-01-17 07:52:29 -08:00
dependabot[bot]
1d2ed2bb42
Bump sphinx from 4.3.2 to 4.4.0 in /docs (#2776)
Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 4.3.2 to 4.4.0.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/4.x/CHANGES)
- [Commits](https://github.com/sphinx-doc/sphinx/compare/v4.3.2...v4.4.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-01-17 06:50:27 -08:00
Batuhan Taskaya
33e3bb1e4e
[trivial] Use proper test cases on unittest (#2775) 2022-01-15 14:19:37 -08:00
Marco Edward Gorelli
5fe6d48fcd
Dont require typing-extensions in 3.10 (GH-2772)
3.10 ships with TypeGuard which is the newest feature we need.

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2022-01-14 23:24:55 -05:00
Richard Si
565f9c92b7
CI: add diff-shades integration (#2725)
Hopefully this makes it much easier to gauge the impacts of future
changes!
2022-01-13 18:50:02 -08:00
VanSHOE
5543d1b55a
Added decent coloring (#2712) 2022-01-13 18:31:08 -08:00
Batuhan Taskaya
7a29568115
Don't make redundant copies of the DFA (#2763) 2022-01-13 18:01:44 -08:00
Felix Hildén
799f76f537
Normalise string prefix order (#2297)
Closes #2171
2022-01-13 09:59:43 -08:00
Jelle Zijlstra
f298032ddb
don't expect changes on poetry (#2769)
They just made themselves ESP-compliant in ecb030e1f0
2022-01-13 09:33:56 -08:00
Jeffrey Lazar
8954e58ccf
Change installation url to comply with git security change (#2765)
Co-authored-by: Jeffrey Lazar <jlazar@MacBook-Pro-2.local>
2022-01-11 14:37:07 -08:00
cbows
4efb795129
Change git url for pip installation in README (#2761)
* Change git url for pip installation in README

Unauthenticated git protocol was disabled recently by Github and should not be used anymore.

https://github.blog/2021-09-01-improving-git-protocol-security-github/#no-more-unauthenticated-git

* Update CHANGES.md
2022-01-11 09:31:07 -08:00
Batuhan Taskaya
0f26a0369e
Fix handling of standalone match/case with newlines/comments (#2760)
Resolves #2759
2022-01-10 12:22:07 -08:00
Batuhan Taskaya
3e731527e4
Speed up new backtracking parser (#2728) 2022-01-10 10:22:00 -08:00
Shivansh-007
521d1b8129
Enhance --verbose (#2526)
Black would now echo the location that it determined as the root path
for the project if `--verbose` is enabled by the user, according to
which it chooses the SRC paths, i.e. the absolute path of the project
is `{root}/{src}`.

Closes #1880
2022-01-10 05:58:35 -08:00
Richard Si
e401b6bb1e
Remove Python 2 support (#2740)
*blib2to3's support was left untouched because: 1) I don't want to touch
parsing machinery, and 2) it'll allow us to provide a more useful error
message if someone does try to format Python 2 code.
2022-01-10 04:16:30 -08:00
Batuhan Taskaya
e64949ee69
Fix call patterns that contain as-expression on the kwargs (#2749) 2022-01-07 18:51:36 +02:00
Josh Owen
ea4c772746
Action: Support running in a docker container (#2748)
see: https://github.com/actions/runner/issues/716
2022-01-07 18:50:50 +02:00
Richard Si
05e1fbf27d
Stubs: preserve blank line between attributes and methods (#2736) 2022-01-07 18:38:03 +02:00
Felix Hildén
668bace2ab
Improve CLI reference wording (#2753) 2022-01-07 18:19:03 +02:00
Gunung Pambudi Wibisono
8a84bebcfc
Documentation: include Wing IDE 8 integrations (GH-2733)
Wing IDE 8 now supports autoformatting w/ Black natively 🎉

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2022-01-01 22:33:20 -05:00
Richard Si
4f5268af4f
Primer: exclude crashing sqlalchemy file for now (GH-2735)
Until we can properly look into and fix it.
-> https://github.com/psf/black/issues/2734
2021-12-30 19:59:53 -05:00
Jelle Zijlstra
b8df7e4b10
Drop upper version bounds on dependencies (GH-2718)
They mostly cause unnecessary trouble.

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2021-12-30 16:17:11 -05:00
Miro Hrončok
092959ff1f
Support pytest 7 by fixing broken imports (GH-2705)
The tmp_path related changes are not necessary to make pytest 7 work,
but it feels more complete this way.
2021-12-24 22:28:43 -05:00
Marco Edward Gorelli
ced2d65679
remove all type: ignores in src/black (GH-2720)
Excet
;t
2021-12-24 21:25:03 -05:00
Felix Hildén
f0a99f6402
Update contributing wording (#2719)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2021-12-21 10:43:10 -08:00
Batuhan Taskaya
3fafd806b3
Support multiple top-level as-expressions on case statements (#2716) 2021-12-21 10:16:55 -08:00
Łukasz Langa
c758126a27
Remove usage of Pipenv, rely on good ol' pip and virtualenv in docs (#2717) 2021-12-21 08:24:20 -08:00
Marco Edward Gorelli
7c94ed61a5
Define is_name_token (and friends) to resolve some type: ignores (GH-2714)
Gets rid of a few # type: ignores by using TypeGuard.
2021-12-21 11:20:55 -05:00
Taneli Hukkinen
389e9c23a9
Disable universal newlines when reading TOML (#2408) 2021-12-21 08:03:07 -08:00
dependabot[bot]
c5b458ef4b
Bump myst-parser from 0.16.0 to 0.16.1 in /docs (#2710)
Bumps [myst-parser](https://github.com/executablebooks/MyST-Parser) from 0.16.0 to 0.16.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.16.0...v0.16.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>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-12-20 07:42:03 -08:00
dependabot[bot]
6ef3e466db
Bump sphinx from 4.3.1 to 4.3.2 in /docs (#2709)
Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 4.3.1 to 4.3.2.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/4.x/CHANGES)
- [Commits](https://github.com/sphinx-doc/sphinx/compare/v4.3.1...v4.3.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>
2021-12-20 07:24:53 -08:00
Batuhan Taskaya
b97ec62368
Imply 3.8+ when annotated assigments used with unparenthesized tuples (#2708) 2021-12-17 13:43:14 -08:00