Every one of the projects in this repository is available at the canonical
URL git://git.madduck.net/madduck/pub/<projectpath> — see
each project's metadata for the exact URL.
All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
Richard Si [Wed, 30 Mar 2022 20:40:50 +0000 (16:40 -0400)]
Keep tests working w/ upcoming aiohttp 4.0.0 (#2974)
aiohttp.test_utils.unittest_run_loop was deprecated since aiohttp 3.8
and aiohttp 4 (which isn't a thing quite yet) removes it. To maintain
compatibility with the full range of versions we declare to support,
test_blackd.py will now define a no-op replacement if it can't be
imported.
Also, mypy is painfully slow to use without a cache, let's reenable it.
Richard Si [Sat, 26 Mar 2022 21:22:38 +0000 (17:22 -0400)]
Enforce no formatting changes for PRs via CI (GH-2951)
Now PRs will run two diff-shades jobs, "preview-changes" which formats
all projects with preview=True, and "assert-no-changes" which formats
all projects with preview=False. The latter also fails if any changes
were made.
Pushes to main will only run "preview-changes"
Also the workflow_dispatch feature was dropped since it was
complicating everything for little gain.
Shivansh-007 [Wed, 16 Mar 2022 03:13:56 +0000 (08:43 +0530)]
Remove power hugging formatting from preview (#2928)
It is falsely placed in preview features and always formats the power operators, it was added in #2789 but there is no check for formatting added along with it.
oncomouse [Sat, 5 Mar 2022 00:15:39 +0000 (18:15 -0600)]
Move test for g:load_black to improve plugin performance (GH-2896)
If a vim/neovim user wishes to suppress loading the vim plugin by
setting g:load_black in their VIMRC (for me, Arch linux automatically
adds the plugin to Neovim's RTP, even though I'm not using it), the
current location of the test comes after a call to has('python3'). This
adds, in my tests, between 35 and 45 ms to Vim load time (which I know
isn't a lot but it's also unnecessary). Moving the call to
`exists('g:load_black')` to before the call to `has('python3')` removes
this unnecessary test and speeds up loading.
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
D. Ben Knoble [Mon, 21 Feb 2022 01:37:07 +0000 (20:37 -0500)]
correct Vim integration code (#2853)
- use `Black` directly: the commands an autocommand runs are Ex commands, so no
execute or colon is necessary.
- use an `augroup` (best practice) to prevent duplicate autocommands from
hindering performance.
Jelle Zijlstra [Sun, 30 Jan 2022 22:04:06 +0000 (14:04 -0800)]
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.
Nipunn Koorapati [Sat, 29 Jan 2022 02:13:18 +0000 (18:13 -0800)]
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)
Shantanu [Sat, 29 Jan 2022 00:57:05 +0000 (16:57 -0800)]
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.
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.
Jelle Zijlstra [Thu, 27 Jan 2022 01:18:43 +0000 (17:18 -0800)]
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.
Richard Si [Tue, 25 Jan 2022 03:13:34 +0000 (22:13 -0500)]
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.
Felix Hildén [Mon, 24 Jan 2022 15:35:56 +0000 (17:35 +0200)]
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.
Perry Vargas [Sat, 22 Jan 2022 06:00:33 +0000 (22:00 -0800)]
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.
Richard Si [Fri, 21 Jan 2022 23:00:13 +0000 (18:00 -0500)]
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
Michael Marino [Fri, 21 Jan 2022 00:45:28 +0000 (01:45 +0100)]
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.
Shivansh-007 [Mon, 10 Jan 2022 13:58:35 +0000 (19:28 +0530)]
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}`.
Richard Si [Mon, 10 Jan 2022 12:16:30 +0000 (07:16 -0500)]
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.