Commit Graph

925 Commits

Author SHA1 Message Date
Cooper Lees
8e0803e7e5
Add black Dockerfile (#1916)
* Add `black` Dockerfile
- Build a `black` container based on python3-slim
- Test: `docker build --network-host --tag black .`
```console
cooper-mbp1:black cooper$ docker image ls
REPOSITORY                                         TAG            IMAGE ID       CREATED              SIZE
black                                              latest         0c7636402ac2   4 seconds ago        332MB
```

Addresses part of #1914

* Build with colorama + d extra installs - Adds ~9mb

* Combine all build commands in 1 run
- Combine the commands all into 1 RUN to down the size
- Get to 65.98 MB image size now: https://hub.docker.com/repository/docker/cooperlees/black/tags?page=1&ordering=last_updated

* Add rm -r of /var/lib/apt/lists/* + save 10mb down to 55mb
2021-04-07 21:13:11 -07:00
dependabot[bot]
9cbf1f1622
Bump urllib3 from 1.26.3 to 1.26.4 (#2090)
Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.26.3 to 1.26.4.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](https://github.com/urllib3/urllib3/compare/1.26.3...1.26.4)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-06 11:07:57 -07:00
Jakub Warczarek
e114ef5514
Get rid of redundant spaces in docs (#2085)
Thanks!
2021-04-04 07:21:33 -07:00
Cooper Lees
201b331e55
Run lint in latest python + update precommit (#2081)
- Lets move to latest and greatest of lints
2021-04-01 16:15:50 -07:00
Richard Si
48dfda084a
Push contributors to use Next PR Number (#2080)
This is a tool of my own making. Right now our requirement to have the
PR number in the changelog entry is pretty painful / annoying since
the contributor either has to guess or add the # retroactively after
the PR creation. This tool should make it way less painful by making
it simple to get your PR number beforehand.
2021-04-01 14:24:18 -07:00
Cooper Lees
53a6216cd5
Add CONTRBUTING info about CHANGES.md requirement (#2073)
Instruct contributors to add the change line to help save maintainer / releaser time
2021-04-01 18:54:45 +02:00
Cooper Lees
125ed5b260
Add a GitHub Action to build + Upload black to PyPI (#1848)
* Add a GitHub Action to build + Upload black to PyPI
- Build a wheel + sdist
- Upload via twine using token stored in GitHub secrets
2021-04-01 18:41:55 +02:00
Harish Rajagopal
9451c57d1c
Support for top-level user configuration (#1899)
* Added support for top-level user configuration

At the user level, a TOML config can be specified in the following locations:
* Windows: ~\.black
* Unix-like: $XDG_CONFIG_HOME/black (~/.config/black fallback)

Instead of changing env vars for the entire black-primer process, they
are now changed only for the black subprocess, using a tmpdir.
2021-04-01 18:39:18 +02:00
KotlinIsland
ed9d58b741 don't require typed-ast 2021-04-01 17:38:04 +02:00
dependabot[bot]
c702588daa
Bump pygments from 2.6.1 to 2.7.4 in /docs (#2076)
Bumps [pygments](https://github.com/pygments/pygments) from 2.6.1 to 2.7.4.
- [Release notes](https://github.com/pygments/pygments/releases)
- [Changelog](https://github.com/pygments/pygments/blob/master/CHANGES)
- [Commits](https://github.com/pygments/pygments/compare/2.6.1...2.7.4)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-03-29 18:59:57 -07:00
Mark Bell
dc8b0a4383
GREP for PR reference accepts references that are split over a line (#2072)
Fixes #2070
2021-03-28 16:01:37 -07:00
Shantanu
4218ae18c0
Add --skip-magic-trailing-comma to CHANGES.md (#2064) 2021-03-26 07:21:18 -07:00
Richard Si
580b4fe8bc
Add entry for --extend-exclude in the right place (#2061)
The PR author added the changelog entry for their `extend-exclude` addition
in `docs/change_log.md` which is understandable but incorrect as it will be
overwritten since it's autogenerated from the readme.
2021-03-24 16:38:07 -07:00
Cooper Lees
5d33f20a2a
Add a GitHub CHANGELOG/News Check (#2057)
- Run grep to see commit has a line mentioning it to CHANGES.md
- Also add a label to disable this being required for PRs that don't need a change entry
2021-03-21 13:05:24 -07:00
Richard Si
0be7f96d9c
Fix indentation in docs/editor_integration.md (#2056)
Numbered list entries' bodies need to be indented or else the list won't
render correctly.
2021-03-20 12:15:55 -07:00
Jairo Llopis
d62d677ca2
Recommend B950 + 88 char limit instead of 80 (#2050)
[The section about line length][1] was contradictory.

On one side, it said:

> Black will try to respect that [line length limit]. However, sometimes it won't be able to without breaking other rules. In those rare cases, auto-formatted code will exceed your allotted limit.

So black doesn't guarantee that your code is formatted at 88 chars, even when configured with `--line-length=88` (default). Black uses this limit as a "hint" more than a "rule".

OTOH, it also said:

> If you're using Flake8, you can bump max-line-length to 88 and forget about it. Alternatively, use Bugbear's B950 warning instead of E501 and keep the max line length at 80 which you are probably already using.

But that's not true. You can't "forget about it" because Black sometimes won't respect the limit. Both E501 at 88 and B950 at 80 behave the same: linter error at 89+ length. So, if Black happens to decide that a line of code is better at 90 characters that some other fancy style, you land on a unlucky situation where both tools will fight.

So, AFAICS, the best way to align flake8 and black is to:

1. Use flake8-bugbear
2. Enable B950
3. Disable E501
4. Set `max-line-length = 88`

This way, we also tell flake8 that 88 limit is a "hint" and not a "rule". The real rule will be 88 + 10%. If black decides that a line fits better in 97 characters than in 88 + some formatting, _that_ probably means your code has a real problem.

To avoid further confusion, I change the official recommendation here.

[1]: e82bb8d8b8 (opinionated-warnings)
2021-03-18 08:14:15 -07:00
Konstantin Alekseev
5446a92f01
Use vim autoload script (#1157) 2021-03-07 16:13:25 -08:00
Richard Si
b332cfa655
Add missing changelog entry for fmt: skip (#2025) 2021-03-06 12:02:25 -08:00
John Meow
1f7e73506c
Add ALE (#1753) 2021-03-05 20:22:19 -08:00
Hadi Alqattan
b3ceb293d9
Remove unused import statements using Pycln. (#2021)
* remove unused imports using Pycln.

* reverse comma style.
2021-03-05 11:58:00 -08:00
dependabot[bot]
12f98219bc
Bump aiohttp from 3.7.3 to 3.7.4 (#2009)
Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.7.3 to 3.7.4.
- [Release notes](https://github.com/aio-libs/aiohttp/releases)
- [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst)
- [Commits](https://github.com/aio-libs/aiohttp/compare/v3.7.3...v3.7.4)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-03-05 10:43:54 -08:00
Hugo van Kemenade
24418a5450
Black requires Python 3.6.2+ (#1668) 2021-03-04 05:59:31 -08:00
Utkarsh Gupta
e293473ea9
Add formatters-python for atom to editor_integration (#1834) 2021-03-03 16:46:27 -08:00
Joshua Cannon
e3c71c3a47
Turn test_regex into a click callback (#2016)
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2021-03-02 17:21:50 -08:00
Austin Pray
cac18293d5
Adds --stdin-filename back to changelog (#2017)
* Adds --stdin-filename back to changelog

Looks like this went missing dea81b7ad5 (diff-729efdd61772b108539268bdbfd7472521bdc05a7cae6113f62ed2649a3ad9c7)

* Update CHANGES.md

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>

* Update CHANGES.md

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2021-03-01 16:35:57 -08:00
Joshua Cannon
beecd6fd0a
Add --extend-exclude parameter (#2005)
Look ma! I contribute to open source!

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2021-03-01 14:07:36 -08:00
Rishav Kundu
858225d34d
Strip redundant parentheses from assignment exprs (#1906)
Fixes #1656
2021-02-27 17:20:23 -08:00
tpilewicz
b06cd15666
Wrap arithmetic and binary arithmetic expressions in invisible parentheses (#2001) 2021-02-24 03:56:56 -08:00
James Addison
e1c86f987e
Fuzzer testing: less strict special-case regex match passthrough for multi-line EOF exceptions (#1998) 2021-02-22 07:49:38 -08:00
James Addison
fe4a9d6bee
Fixup: update function name in docs to match source (#1997) 2021-02-22 07:46:38 -08:00
James
24e8dad575
Fix for enum changes in 3.10 (#1999) 2021-02-22 07:42:05 -08:00
Paul "TBBle" Hampson
cd4295dd98
Indicate that a final newline was added in --diff (#1897) (#1897)
Fixes: #1662

Work-around for https://bugs.python.org/issue2142

The test has to slightly mess with its input data, because the utility
functions default to ensuring the test data has a final newline, which
defeats the point of the test.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2021-02-21 22:43:23 -08:00
James Addison
0cbe19c813 Minimize changes: more closely resemble original conditional logic 2021-02-20 19:36:21 +01:00
James Addison
22127c633e Readability: reduce boolean nesting 2021-02-20 19:36:21 +01:00
James Addison
24700806f6 Cleanup: remove unused / redundant variables from conditionals 2021-02-20 19:36:21 +01:00
James Addison
e0d766727d Simplification: only yield empty omit list when magic trailing comma is present 2021-02-20 19:36:21 +01:00
James Addison
829331a877 Simplification: only use special-case token retrieval logic when magic trailing comma is present 2021-02-20 19:36:21 +01:00
James Addison
89c42a0011 Clarity: special case: avoid using variables that have the same names as methods 2021-02-20 19:36:21 +01:00
James Addison
51141f1af4 Consistency: use variable names that correspond to the methods they invoke 2021-02-20 19:36:21 +01:00
James Addison
a23f521fee Brevity: only use the variables required to convey the intended expressions 2021-02-20 19:36:21 +01:00
James Addison
caa3fcc2de Clarity: isolate and extract each responsibility from an overloaded variable 2021-02-20 19:36:21 +01:00
James Addison
afc8c326bf Brevity: rename method 2021-02-20 19:36:21 +01:00
James Addison
306a513137
fuzzer: add special-case for multi-line EOF TokenError (#1991)
* Add special-case for multi-line EOF TokenError under Python3.7

* Update conditional check to correspond to original issue description (and include issue hyperlink)

* Add warning and hint regarding replaying the fuzzer code generation

* Include code review suggestion (with modifications for this to follow)

Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>

* Remove Python version check, since this issue does exist across more recent Python versions than 3.7

* Update explanatory comment

* Add clarification for potentially-ambiguous blib2to3 import

* Update explanatory comment

* Bring comment into consistent format with previous comment

* Revert "Add clarification for potentially-ambiguous blib2to3 import"

This reverts commit 357b7cc03bdb19dd924f1accd428352f4bb44e5c.

Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
2021-02-20 08:44:48 -08:00
Romain Rigaux
97b8496d67
Use 'args' to Avoid GH workflow warning (#1990)
Unexpected input(s) 'black_args', valid inputs are ['entryPoint', 'args']
2021-02-16 13:10:23 -08:00
Archit Gopal
71bbb678b9
add gedit integration (#1988) 2021-02-15 08:05:23 -08:00
Sagi Shadur
6a105e019f
Add "# fmt: skip" directive to black (#1800)
Fixes #1162
2021-02-15 08:02:48 -08:00
rht
3a309a36fc
readme: Include Zulip in used-by section (#1987)
Zulip has recently formatted their code in Black and also set Black as a linter: https://github.com/zulip/zulip/pull/15662.
See also https://chat.zulip.org/#narrow/stream/2-general/topic/black.
2021-02-14 07:32:29 -08:00
Richard Si
76268ab0c9
Fix duplication of checks on internal PRs (#1986)
Internal PRs (that come from branches of psf/black) match both the push
and pull_request events. This leads to a duplication of test, lint, etc.
checks on such PRs. Not only is it a waste of resources, it makes the
Status Checks UI more frustrating to go through.

Patch taken from:
https://github.community/t/duplicate-checks-on-push-and-pull-request-simultaneous-event/18012
2021-02-14 07:23:47 -08:00
James Addison
b8c1020b52
Stability fixup: interaction between newlines and comments (#1975)
* Add test case to illustrate the issue

* Accept carriage returns as valid separators while enumerating comments

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

* Remove comment linking to ephemeral build log
2021-02-11 12:11:42 -08:00
dependabot[bot]
2d0c14989d
Bump cryptography from 3.3.1 to 3.3.2 (#1981)
Bumps [cryptography](https://github.com/pyca/cryptography) from 3.3.1 to 3.3.2.
- [Release notes](https://github.com/pyca/cryptography/releases)
- [Changelog](https://github.com/pyca/cryptography/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pyca/cryptography/compare/3.3.1...3.3.2)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-09 18:17:23 -08:00