Commit Graph

356 Commits

Author SHA1 Message Date
Jakub Warczarek
e114ef5514
Get rid of redundant spaces in docs (#2085)
Thanks!
2021-04-04 07:21:33 -07: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
Hugo van Kemenade
24418a5450
Black requires Python 3.6.2+ (#1668) 2021-03-04 05:59:31 -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
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
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
Oliver Newman
71117e730c
Update example exclude to match only files in root (#1861)
* Update example exclude to match only files in root

The `exclude` section of the example `pyproject.toml` file didn't work
as expected. It claimed to exclude matched files only in the project
root, but it actually excluded matched files at any directory level
within the project. We can address this by prepending `^/` to the regex
to ensure that it only matches files in the project root.

See https://github.com/psf/black/issues/1473#issuecomment-740008873 for
explanation.

* Mention excluding directories as well
2021-01-27 09:36:21 -08:00
Shantanu
692c0f50d9
Add --skip-magic-trailing-comma (#1824) 2021-01-17 16:59:06 -08:00
Rick Staa
ba3648d984
Release gh action (#1909)
* Gets gh-action ready for marketplace release

* Updates documentation and removes redundant gh-action input argument

* Fixes gh-action bug

This commit fixes a bug which caused not all input arguments were forwarder to the black formatter.

* Update README.md

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

Co-authored-by: Cooper Lees <me@cooperlees.com>
2021-01-08 11:47:03 -08:00
Thiago Bellini Ribeiro
dea81b7ad5
Provide a stdin-filename to allow stdin to respect force-exclude rules (#1780)
* Provide a stdin-filename to allow stdin to respect exclude/force-exclude rules

This will allow automatic tools to enforce the project's
exclude/force-exclude rules even if they pass the file through stdin to
update its buffer.

This is a similar solution to --stdin-display-name in flake8.

* Update src/black/__init__.py

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

* --stdin-filename should only respect --exclude-filename

* Update README with the new --stdin-filename option

* Write some tests for the new stdin-filename functionality

* Apply suggestions from code review

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>

* Force stdin output when we asked for stdin even if the file exists

* Add an entry in the changelog regarding --stdin-filename

* Reduce disk reads if possible

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

* Check for is_stdin and p.is_file before checking for p.is_dir()

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2020-11-13 07:26:07 -08:00
Antek S
989ea69bd1
Update readme.md with current version (#1788)
* Update readme.md with current version

* Update version_control_integration.md
2020-10-27 11:52:19 +01:00
David W.H. Swenson
3e3da8eef6
Fix GitHub markdown links to work on RTD (#1752)
* Fix internal links to work on RTD

Note that these still lead to GitHub, instead of staying on RTD.

* Point links to better anchors
2020-10-18 14:27:15 -07:00
Hadi Alqattan
4d6a84a829
Allow black's Github action params overriding. (#1755)
* Allow default params overriding.

* Update: docs and action.yaml.

* The second contirbution, add my name to authors.md

* Correct docs `with.args` example.

* Just to rerun the Travis jobs.

* chmod 755
2020-10-18 14:24:33 -07:00
Hadi Alqattan
dd2f86ac0a
Support stable Python3.9. (#1748)
* Support stable Python3.9.

* Get back to 3.9-dev

* Add py39 to black usage.

* remove 3.9 temporarily.
2020-10-08 14:13:13 -07:00
Cha Gyuseok
d9884b6d33
docs: update used-by link to proper url (#1745) 2020-10-07 07:45:06 -07:00
Pete Grayson
4d71d74a44
Repair colorama wrapping on non-Windows platforms (#1670)
* Repair colorama wrapping on non-Windows platforms

The wrap_stream_for_windows() function calls
colorama.initialise.wrap_stream() function to apply colorama's magic to
wrapper to the output stream. Except this wrapper is only applied on
Windows platforms that need it, otherwise the original stream is
returned as-is.

The colorama wrapped stream lacks a detach() method, so a no-op lambda
was being assigned to the wrapped stream.

The problem is that the no-op lambda was being assigned unconditionally
whether or not colorama actually returns a wrapped stream, thus
replacing the original TextIOWrapper's detach() method. Replacing the
detach() method with a no-op lambda is the root cause of the problem
observed in #1664.

The solution is to only assign the no-op detach() method if the stream
lacks its own detach() method.

Repairs #1664
2020-09-27 22:41:11 +01:00
Vipul
bc138d1263
End 'force-exclude' help message with a period (#1727)
It would be nice, if like other options help message, force-exclude's
help message also ends with a period punctuation mark.
2020-09-27 07:54:21 +02:00
Michael Wilkinson
1e8916f450
Add link to conda-forge integration (#1687)
* Add link to conda-forge integration

resolves #1686

* README: keep PyPI tags together

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2020-09-08 09:42:57 -07:00
Zac-HD
cd3a93a146 Property-based fuzz test 2020-08-21 16:47:49 +02:00
Richard Si
37a0020e07
Upgrade docs to Sphinx 3+ and add doc build test (#1613)
* Upgrade docs to Sphinx 3+
* Fix all the warnings...

- Fixed bad docstrings
- Fixed bad fenced code blocks in documentation
- Blocklisted some sections from being generated from the README
- Added missing documentation to index.rst
- Fixed an invalid autofunction directive in reference/reference_functions.rst
- Pin another documentation dependency

* Add documentation build test
2020-08-21 00:06:41 +02:00
Daanyaal Syed
80425ca440
Fix inline code style in README (#1608)
Refer to `pyproject.toml` in HTML section of README with HTML code tags
2020-08-17 11:55:38 -07:00
Chris Rose
149b38d674
Add the direnv base directory to the default excludes (#1564)
Co-authored-by: Chris Rose <offline@offby1.net>
2020-08-12 19:28:01 -07:00
Kaligule
b59a524657
fix spelling (#1567)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2020-08-01 14:21:55 -07:00
Vinicius Gubiani Ferreira
2c5041cfa0
docs: Improve pre-commit use (#1551)
Stable tag wasn't available and crashed when attempting to set initial
pre-commit. Also the python version needs to be installed so it would
be better to use the generic "python3" command.
2020-07-15 21:51:39 -07:00
Olexiy
cc2facaac6
ISSUE 1533: Fix --config argument description (#1534)
Change --config argument description to "Read configuration from FILE."
The "--config FILE                   Read configuration from FILE path"
2020-07-08 08:51:18 -07:00
Jelle Zijlstra
11f130b7de
add Quora to orgs that use Black (#1532) 2020-07-06 12:45:13 -07:00
Sylvestre Ledru
3209bf7ffa
Mozilla uses black too (#1531) 2020-07-06 07:06:34 -07:00
Cooper Lees
81a093e82a
Add pip install from GitHub command to README.md (#1529)
* Add pip install from GitHub command to README.md
* Make it prettier ...
2020-07-01 08:15:24 -07:00
Richard Si
d3cc63316b
Add missing contributors to README.md (Thank you everyone!) (#1508)
Black wouldn't be where it is without the countless outside contributions.
So thank you y'all and we will share our appreciation by listing your names
(and emails) in the README.md :D
2020-06-18 11:54:02 +01:00
Hugo Barrera
fcf9796106
GitHub action (#1421)
* Implement a re-usable GitHub Action

Implement a GitHub action that can be reused across projects that want
to run black as part of their CI workflows.

* Fix typo in README.md

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>

* Use latest Python 3

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2020-06-01 11:11:49 -07:00
Richard Si
34613383ab
Make 'python -m black' work (#1460) 2020-05-26 19:42:07 -07:00
Richard Si
7403d95862
Refactor docs / Maintenance of docs (#1456)
* Split code style and components documentation

Splits 'the_black_code_style', 'pragmatism', 'blackd',and 'black_primer'
into their own files. The exception being 'the_black_code_style' and
'pragmatism'. They have been merged into one 'the_black_code_style_and_pragmatism'
file.

These changes are being made because the README is becoming very long. And
a README isn't great if it dissuades its reader because of its length.

* Update the doc generation logic and configuration

With the moving of several sections in the README and the renaming of a
few files, 'conf.py' needs to be able to support custom sections.

This commit introduces DocSection which can be used to specify custom
sections of documentation. The information stored in DocSection will be
used by the process_sections function to read, process, and write the section
to CURRENT_DIR.

A large change has been made to the how the docs are prepared to be built.
Instead of just generating the files needed by reading the README, this
has a full chain of operations so custom sections are supported. First,
it reads the README and spits out a list of DocSection objects representing
the sections to be generated by process_sections. This is done since most
of the docs still live in README. Then along with the defined custom_sections
, the process_sections will be begin to process the DocSection objects.
It reads the information it needs to generate the section. Then fetches
the section's contents, calls processors required by the section to process
the section's contents, and finally writes the section to CURRENT_DIR.

This large change is so processing of the documentation can be done just
for the versions hosted on ReadTheDocs.org. An example processor using this
feature is a 'replace_links' processor. It will replace documentation
links that point to the docs hosted on GitHub with links that point to the
version hosted on ReadTheDocs.org. (I won't be coding that ATM)

This also means that files will be overwritten or created once the docs
have been built. It is annoying, since you have to 'git reset --hard'
and 'git clean -f -d' after each build, but there's nothing better. The old
system had the same side effects, so yeah :(

* Update filenames and delete unnecessary files

Update the filenames since 'the_black_code_style' and 'pragmatism' were
merged and 'contributing' was deleted in favor of 'contributing_to_black'.

All symlinks were deleted since their home (_build/generated) is no longer
used.

* Fix broken links and a few redirections

* Merge master into refactor_docs (manually done)

* Add my and most of @hugovk suggestions

Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>

* Add logging and improve configurability

Just some cleaning up up of the DocSection dataclass and added logging
support so you know what's going on.

* Rename a section and please the grammar gods of Black

Thanks @hugovk for the suggestion!

* Fix Markdown comments

* Add myself as an author :P

Seems like the right time.

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2020-05-24 09:37:46 -07:00
Richard Si
0196437f8e
Scrollable sidebar (#1457)
* Make the sidebar navigation scrollable

This is necessary since we have so many documentation sections that even
on a desktop screen, the navigation can sometimes be clipped. The only
annoyance is that on Firefox, the scrollbar can't be hidden :(

* allow the docs to build
2020-05-23 11:56:50 -07:00
Cooper Lees
c77cb7b97e
Add Primer badge to README.md (#1454) 2020-05-22 12:15:41 -07:00
Gustavo Camargo
397b16431e
Update README.md (#1453) 2020-05-22 11:37:34 -07:00
Hugo van Kemenade
a2408b3cb2
black-primer: handle singular and plural in output messages (#1432)
* Handle singular and plural in output messages
2020-05-20 21:03:51 -07:00
Gustavo Camargo
bb767863b0
Update README.md (#1439) 2020-05-20 20:50:16 -07:00
Cooper Lees
b0f3798aab
Add black-primer docs (#1427)
* Add `black-primer` docs

- Document the idea, CLI args, config and a example run for `black-primer` in README.md
- Add to docs/index.rst

* Add @hugovk suggestions - Thanks.
2020-05-18 07:25:40 -07:00
Richard Si
f62f1ddc2f
Update docs about stable tag now being a branch (#1422)
* Update docs about stable tag now being a branch

Issue #760 had the `stable` tag changed to a branch since it was causing a few issues. This updates the docs to reflect that change.

* Make the prettier hook pass

* Improve wording
2020-05-17 12:19:52 -07:00
Hugo van Kemenade
435dc7d995
Fix typos (#1423) 2020-05-17 07:17:31 -07:00
Richard Si
12e857f24c
Document git's ignore-revs-file feature (#1419)
* Document git's ignore-revs-file feature

A long-standing counterargument against moving to automated code formatters
like Black is that the migration will clutter up the output of git blame.
This used to be a valid argument, but not anymore. Since git version 2.23,
git natively supports ignoring revisions in blame with the --ignore-rev
and --ignore-revs-file options.

This isn't documented in the Black documentation. It should be as it would
put old projects wanting to migrate to Black at ease since blame won't
be ruined.

* Add links so people can +1 on --ignore-revs-file support

* Fix wording

'Counterargument' was the wrong word since it means an objection to an objection. 'Argument' is the proper word I was looking for.

Co-authored-by: Cooper Lees <me@cooperlees.com>
2020-05-16 13:22:46 -07:00
Richard Si
97060a4f18
Expand docs about slice formatting (#1418)
Black will apply no spaces around ':' operators for 'simple' expresssions
, but will apply extra space around ':' operators for 'complex' expressions.
Black treats anything more than variable names as 'complex', but this isn't
noted in the Black documentation. Which leads to a few issues on the GitHub
issue tracker that all report inconsistent spacing around ':' operators.
2020-05-16 10:21:31 +01:00
Sanket Dasgupta
f6393a20fc
Add preference of parantheses over backslashes in docs (#1399)
Closes https://github.com/psf/black/issues/392

Revived from https://github.com/psf/black/pull/558

Relevant to https://github.com/psf/black/issues/664
2020-05-09 06:32:29 -07:00
Hugo van Kemenade
4501f22fcb
README/CHANGES: Fix links (#1397)
* Replace relative README links with absolutes, so they work on PyPI

* CHANGES: Fix Spyder web link
2020-05-08 12:14:27 -07:00
shaoran
0721f11731
Adding documentation to the README for import errors in vim (#1317)
* Adding documentation to the README for import errors in vim

I had the same issue as psf/black#1148 and have been searching for a
solution to this. I realized that you cannot fix it by change anything
in the code, but by re-compiling the C extensions of regex and
typed-ast. Installing this packages from the tarballs solves the
problem.

* Fixing a bad copy&paste

Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>

* chore: changed made by pre-commit

* chore: better way of dealing with non-binary installs

* chore: adding vim cache files to the ignore list

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2020-05-08 08:42:19 -07:00
Dan Davison
2da2c15b21
Add purcell/reformatter.el as an Emacs integration option (#1330) 2020-05-08 16:31:06 +01:00
Jelle Zijlstra
702e459176
Update changelog and README (#1392)
* add two CHANGELOG entries

* update README on command-line options
2020-05-08 07:55:57 -07:00
Hugo van Kemenade
8e38b6626b
Remove deprecated --py36 option (#1236) 2020-05-08 07:47:54 -07:00