Commit Graph

978 Commits

Author SHA1 Message Date
Kaleb Barrett
1fe2efd857
Do not use gitignore if explicitly passing excludes (#2170)
Closes #2164.

Changes behavior of how .gitignore is handled. With this change, the rules in .gitignore are only used as a fallback if no exclusion rule is explicitly passed on the command line or in pyproject.toml. Previously they were used regardless if explicit exclusion rules were specified, preventing any overriding of .gitignore rules.

Those that depend only on .gitignore for their exclusion rules will not be affected. Those that use both .gitignore and exclude will find that exclude will act more like actually specifying exclude and not just another extra-excludes. If the previous behavior was desired, they should move their rules from exclude to extra-excludes.
2021-05-07 14:54:21 +02:00
Richard Si
4b7b5ed5b8
Fix broken Action entrypoint (#2202) 2021-05-06 12:21:13 -07:00
Shota Ray Imaki
5316836393
Simplify GitHub Action entrypoint (#2119)
This commit simplifies entrypoint.sh for GitHub Actions by removing
duplication of args and black_args (cf. #1909).

The reason why #1909 uses the input id black_args is to avoid an overlap
with args, but this naming seems redundant. So let me suggest option
and src, which are consistent with CLI. Backward compatibility is
guaranteed; Users can still use black_args as well.

Commit history pre-merge:
* Simplify GitHub Action entrypoint (#1909)
* Fix prettier
* Emit a warning message when `black_args` is used

  This deprecation should be visible in GitHub Action's UI now.

  Co-authored-by: Shota Ray Imaki <shota.imaki.0801@gmail.com>
  Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2021-05-05 22:25:43 -04:00
Cooper Lees
07c8812937
Enable --experimental-string-processing on most primer projects (#2184)
* Enable ` --experimental-string-processing` on all primer projects
- We want to make this default so need to test it more
- Fixed splat/star bug in extending black args for each project

* Disable sqlalchemy due to crash
2021-05-05 08:33:23 -07:00
Cooper Lees
14c76e8971
Disable pandas while we look into #2193 (#2195) 2021-05-04 12:49:20 -07:00
Cooper Lees
d8a034f9b6
Update CHANGES.md for 21.5b0 release (#2192)
* Update CHANGES.md for 21.5b0 release

* Make prettier happy
2021-05-04 11:07:08 -07:00
Hugo van Kemenade
267bc5dde9
Use pre-commit/action to simplify CI (#2191) 2021-05-04 13:41:04 +02:00
reka
0c60ccc066
compatible isort config: mention profile first (#2180)
Change the order of possible ways to configure isort:
1. using the profile black
2. custom configuration

Formats section:
change the examples to use the profile black

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2021-05-04 10:48:59 +02:00
Richard Si
5918a016ff
Drop Travis CI and migrate Coveralls (#2186)
Travis CI for Open Source is shutting down in a few weeks so the queue
for jobs is insane due to lower resources. I'm 99.99% sure we don't need
it as our Test, Lint, Docs, Upload / Package, Primer, and Fuzz workflows
are all on GitHub Actions. So even though we *can* migrate to the .com
version with its 1000 free Linux minutes(?), I don't think we need to.

more information here:
- https://blog.travis-ci.com/oss-announcement
- https://blog.travis-ci.com/2020-11-02-travis-ci-new-billing
- https://docs.travis-ci.com/user/migrate/open-source-repository-migration

This commit does the following:
- delete the Travis CI configuration
- add to the GHA test workflows so coverage continues to be recorded
  - tweaked coverage configuration so this wouldn't break
- remove any references to Travis CI in the docs (i.e. readme + sphinx
  docs)

Regarding the Travis CI to GitHub Actions Coveralls transition, the
official action doesn't support the coverage files produced by coverage.py
unfornately. Also no, I don't really know what I am doing so don't @ me
if this breaks :p (well you can, but don't expect me to be THAT useful).

The Coveralls setup has two downfalls AFAIK:
- Only Linux runs are used because AndreMiras/coveralls-python-action
  only supports Linux. Although this isn't a big issue since the Travis
  Coveralls configuration only used Linux data too.
- Pull requests from an internal branch (i.e. one on psf/black) will be
  marked as a push coverage build by Coveralls since our anti-duplicate-
  workflows system runs under the push even for such cases.
2021-05-04 10:47:59 +02:00
KotlinIsland
204f76e0c0
add test configurations that don't contain python2 optional install (#2190)
add test for negative scenario: formatting python2 code
tag python2 only tests

Co-authored-by: KotlinIsland <kotlinisland@users.noreply.github.com>
2021-05-04 10:47:22 +02:00
Richard Si
e42f9921e2
Detect '@' dotted_name '(' ')' NEWLINE as a simple decorator (#2182)
Previously the RELAXED_DECORATOR detection would be falsely True on that
example. The problem was that an argument-less parentheses pair didn't
pass the `is_simple_decorator_trailer` check even it should. OTOH a
parentheses pair containing an argument or more passed as expected.
2021-05-04 10:46:46 +02:00
Cooper Lees
a18c7bc099
primer: Add --no-diff option (#2187)
- Allow runs with no code diff output
- This is handy for reducing output to see which file is erroring

Test:
- Edit config for 'channels' to expect no changes and run with `--no-diff` and see no diff output
2021-05-04 10:44:40 +02:00
Cooper Lees
a669b64091
primer: Renable pandas (#2185)
- It no longer crashes black so we should test on it's code
- Update django reason to name the file causing error
  - Seems it has a syntax error on purpose
2021-05-03 14:58:17 -07:00
Bryan Forbes
35e8d1560d
Set is_pyi if stdin_filename ends with .pyi (#2169)
Fixes #2167

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2021-05-02 14:48:54 +02:00
Hugo van Kemenade
24bd6b983a
Tox has been formatted with Black 21.4b0 (#2175) 2021-05-01 12:17:20 -07:00
Kaleb Barrett
00491e1dcb
Add ability to pass posargs to pytest run in tox.ini (#2173) 2021-05-01 14:47:59 -04:00
Łukasz Langa
b39999da7f
Elaborate on what AST changes Black might perform 2021-04-28 16:50:02 +02:00
Cooper Lees
682077c15e
Update CHANGELOG for 21.4b2 release (#2162) 2021-04-28 16:21:56 +02:00
Miro Hrončok
89a856d742
Remove useless shebangs in non-executable files (#2161)
Such shebangs are only ever used if the file is executed directly, i.e.:

    $ /usr/lib/python3.9/site-packages/black_primer/cli.py

But that doesn't work:

    $ /usr/lib/python3.9/site-packages/black_primer/cli.py
    bash: /usr/lib/python3.9/site-packages/black_primer/cli.py: Permission denied

The lib file even has: "lib is a library, funnily enough"
2021-04-28 07:07:15 -07:00
Cooper Lees
04fd4432f6
Add automatic version tagging to Docker CI Pushes (#2132)
* Add automatic version tagging to Docker Uploads
- If the git comment has a tag, set that on the docker images pushed
- If we don't have a tag, we just set `latest_non_release`

* Add trigger on release creation too

* Make prettier happy omn docker.yml
2021-04-27 20:10:44 -07:00
Jelle Zijlstra
ad1696422b
Ignore inaccessible user config (#2158)
Fixes #2157
2021-04-27 14:16:35 -07:00
Jelle Zijlstra
807a65f9d5
Update discussion of AST safety check in README (#2159) 2021-04-27 14:00:17 -07:00
Miro Hrončok
76e1602d60
Install primer.json (used by black-primer by default) with black (#2154)
Fixes https://github.com/psf/black/issues/2153
2021-04-27 08:58:39 -07:00
Jelle Zijlstra
82a53999ea
Add pyanalyze and typeshed to black-primer (#2152)
pyanalyze is one of my projects and it uses `--experimental-string-processing`.

typeshed has a lot of stub files.
2021-04-27 08:33:51 -07:00
Cooper Lees
1728bb441e
Update CHANGELOG for 21.4b1 release (#2151)
* Update CHANGELOG for 21.4b1 release

* Add pathspec minimum bump + update primer not to expect changes for virtualenv
2021-04-27 07:40:08 -07:00
Richard Si
303a0b2c4d
Maintainers += Richard Si (aka ichard26) (#2149) 2021-04-26 16:59:45 -04:00
Richard Si
b55ea63ff4
Stop stripping parens in even more illegal spots (#2148)
We're only fixing them so fuzzers don't yell at us when we break "valid"
code. I mean "valid" because some of the examples aren't even accepted by
Python.
2021-04-26 22:26:43 +02:00
Łukasz Langa
a0b4e609a7
Bump pathspec to >= 0.8.1 to solve invalid .gitignore exclusion handling (#2084)
Also made the Click requirement in Pipfile consistent with setup.py and bumped mypy.
2021-04-26 21:22:25 +02:00
Łukasz Langa
eaa337f176
Add more tests for fancy whitespace (#2147) 2021-04-26 20:24:06 +02:00
Jelle Zijlstra
557b54aa60
Fix crash on docstrings ending with "\ " (#2142)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-04-26 19:42:16 +02:00
Richard Si
97c24664c5
Symlink docs/change_log.md to CHANGES.md, don't copy (#2146)
Super duper janky stopgap fix until I get my documentation reorganization
work done and merged
2021-04-26 10:26:03 -07:00
Richard Si
db30456916
Don't strip parens in assert / return with assign expr (#2143)
Black would previously strip the parenthesis away from statements like this these ones:

    assert (spam := 12 + 1)
    return (cheese := 1 - 12)

Which happens to be invalid code. Now before making the parenthesis invisible, Black
checks if the assignment expression's parent is an assert stamtment, aborting if True.

Raise, yield, and await are already handled fine.

I added a bunch of test cases from the PEP defining asssignment expressions (PEP 572).
2021-04-26 08:28:42 -07:00
Jelle Zijlstra
0a833b4b14
fix magic comma and experimental string cache flags (#2131)
* fix magic comma and experimental string cache flags

* more changelog

* Update CHANGES.md

Co-authored-by: Cooper Lees <me@cooperlees.com>

* fix tests

Co-authored-by: Cooper Lees <me@cooperlees.com>
2021-04-26 07:46:48 +02:00
Cooper Lees
65f0ea6159
Remove Lowercase Hex (PR #1692) from CHANGES.md (#2133)
- It was reverted to not cause so much diff churn on millions of lines of code
- Fix primer config for projects that should now pass
2021-04-25 20:48:04 -07:00
Cooper Lees
67d5532c33
Update CHANGES.md for release (#2129) 2021-04-25 15:12:27 -07:00
Richard Si
de7187a823
Issue 1629 has been closed, let's celebrate! (#2127) 2021-04-25 23:52:23 +02:00
Cooper Lees
eee949e286
Docker CI: Add missed Checkout step (#2128)
- Reading my error others hit it by forgetting this Checkoutstep too so trying the fix
  - e.g. https://github.com/docker/build-push-action/issues/179
- Makes sense it's needed
2021-04-25 23:51:13 +02:00
Cooper Lees
e5490e9623
Add Docker Github Action (#2086)
* Add Docker Github Action
- Build and upload arm64 + amd64 black images on push to master

This will need a `DOCKERHUB_USERNAME` and `DOCKERHUB_TOKEN` secrets set by someone with access.

* Change tag to push to pyfound/black repository. Thanks @ewdurbin
2021-04-25 11:27:35 -07:00
Łukasz Langa
8672af35f0
Work around stability errors due to optional trailing commas (#2126)
Optional trailing commas put by Black become magic trailing commas on another
pass of the tool.  Since they are influencing formatting around optional
parentheses, on rare occasions the tool changes its mind in terms of putting
parentheses or not.

Ideally this would never be the case but sadly the decision to put optional
parentheses or not (which looks at pre-existing "magic" trailing commas) is
happening around the same time as the decision to put an optional trailing
comma.  Untangling the two proved to be impractically difficult.

This shameful workaround uses the fact that the formatting instability
introduced by magic trailing commas is deterministic: if the optional trailing
comma becoming a pre-existing "magic" trailing comma changes formatting, the
second pass becomes stable since there is no variable factor anymore on pass 3,
4, and so on.

For most files, this will introduce no performance penalty since `--safe` is
already re-formatting everything twice to ensure formatting stability.  We're
using this result and if all's good, the behavior is equivalent.  If there is
a difference, we treat the second result as the binding one, and check its
sanity again.
2021-04-25 20:15:54 +02:00
Łukasz Langa
5e09fa07f5
Fix primer config 2021-04-25 19:44:06 +02:00
Łukasz Langa
ea9fefb359
Re-add .venv to .gitignore 2021-04-25 19:42:02 +02:00
Łukasz Langa
773e4a22d5
Revert "Use lowercase hex numbers fixes #1692 (#1775)"
This reverts commit 7d032fa848.
2021-04-25 19:13:23 +02:00
Felix Hildén
368f043f13
Document experimental string processing and docstring indentation (#2106) 2021-04-22 10:37:27 -07:00
CiderMan
5316bbff0e
Handle Docstrings as bytes + strip all whitespace (#2037)
(fixes #1844, fixes #1923, fixes #1851, fixes #2002, fixes #2103)
2021-04-22 08:40:51 -07:00
Mark Bell
1fc3215e8c
Make black remove leading and trailing spaces from one-line docstrings (#1740)
Fixes #1738. Fixes #1812.

Previously, Black removed leading and trailing spaces in multiline docstrings but failed to remove them from one-line docstrings.
2021-04-22 08:23:41 -07:00
Felix Hildén
7b4ca4bd90
Instructions on documenting code style modifications (#2109) 2021-04-18 14:18:39 -07:00
Laurent Tréguier
9eb29a6d47
Fix small comment typo (#2112)
We probably don't need to fall back on "polling" when setting up an asyncio loop
2021-04-16 10:41:19 -07:00
Pierre Verkest
6d0bdc2f38
Add missing instructions to make test passed (#2100) 2021-04-12 06:18:11 -07:00
Pierre Sassoulas
d960d5d238
Remove NBSP at the beginning of comments (#2092)
Closes #2091
2021-04-11 14:41:22 -07:00
Simon
ea4e714b9a
Added not formatting files in gitignore (psf#1682) (#1734) 2021-04-11 14:00:03 -07:00