madduck's git repository
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.
SSH access, as well as push access can be individually
arranged.
If you use my repositories frequently, consider adding the following
snippet to ~/.gitconfig and using the third clone URL listed for each
project:
[url "git://git.madduck.net/madduck/"]
insteadOf = madduck:
Denis Laxalde [Sat, 23 Nov 2019 04:38:46 +0000 (05:38 +0100)]
Simple docs cleanup (#1168)
* Remove reference to format_int_string in docs
The function got dropped in
250ba7f04b300df284ba80cd4bb4122b45b41efb.
* Remove reference to is_python36 in docs
The function got removed in
36d3c516d3c09fc5f05c420900dd6b854e3c8bbd.
Hugo van Kemenade [Fri, 22 Nov 2019 08:14:57 +0000 (10:14 +0200)]
CI: Add Python 3.8 and lint to GitHub Actions (#1173)
* CI: Test Python 3.8 on GitHub Actions
* pre-commit autoupdate
* CI: Lint on GitHub Actions
Anthony Sottile [Fri, 22 Nov 2019 08:13:23 +0000 (00:13 -0800)]
Suggest `extend-ignore` over `ignore` for flake8 (#1165)
this option was introduced in flake8 3.7.x and is generally preferred over `ignore` (which unsets all default ignores)
Tim Gates [Thu, 7 Nov 2019 20:57:39 +0000 (07:57 +1100)]
Fix simple typo: intput -> input (#1146)
Fixes #1147
Richard Fearn [Thu, 31 Oct 2019 00:20:27 +0000 (00:20 +0000)]
Remove duplicate paragraph about blackd headers (#1124)
Michael J. Sullivan [Wed, 30 Oct 2019 14:29:29 +0000 (07:29 -0700)]
Support compilation with mypyc (#1009)
* Make most of blib2to3 directly typed and mypyc-compatible
This used a combination of retype and pytype's merge-pyi to do the
initial merges of the stubs, which then required manual tweaking to
make actually typecheck and work with mypyc.
Co-authored-by: Sanjit Kalapatapu <sanjitkal@gmail.com>
Co-authored-by: Michael J. Sullivan <sully@msully.net>
* Make black able to compile and run with mypyc
The changes made fall into a couple categories:
* Fixing actual type mistakes that slip through the cracks
* Working around a couple mypy bugs (the most annoying of which being
that we need to add type annotations in a number of places where
variables are initialized to None)
Co-authored-by: Sanjit Kalapatapu <sanjitkal@gmail.com>
Co-authored-by: Michael J. Sullivan <sully@msully.net>
Thomas Grainger [Wed, 30 Oct 2019 14:27:20 +0000 (14:27 +0000)]
replace broken rtfd pypi badge (#1120)
Michael J. Sullivan [Wed, 30 Oct 2019 04:06:34 +0000 (21:06 -0700)]
Switch from attrs to dataclasses (#1116)
The main motivation here is that mypyc is going to have custom support
for dataclasses but probably not attrs.
Łukasz Langa [Mon, 28 Oct 2019 21:55:17 +0000 (22:55 +0100)]
Remove Poetry metadata
Hugo van Kemenade [Mon, 28 Oct 2019 20:00:43 +0000 (22:00 +0200)]
Test Windows, macOS and Linux on GitHub Actions (#1085)
Łukasz Langa [Mon, 28 Oct 2019 19:58:06 +0000 (20:58 +0100)]
acks += llchan
Lawrence Chan [Mon, 28 Oct 2019 19:51:45 +0000 (14:51 -0500)]
Fix fmt on/off when multiple exist in leaf prefix (#1086)
The old behavior would detect the existence of a `# fmt: on` in a leaf
node's comment prefix and immediately mark the node as formatting-on,
even if a subsequent `# fmt: off` in the same comment prefix would turn
it back off. This change modifies that logic to track the state through
the entire prefix and take the final state.
Note that this does not fully solve on/off behavior, since any _comment_
lines between the off/on are still formatted. We may need to add
virtual leaf nodes to truly solve that. I will leave that for a separate
commit/PR.
Fixes #1005
Łukasz Langa [Mon, 28 Oct 2019 19:34:37 +0000 (20:34 +0100)]
Always move the prefix out when wrapping with parentheses (#1103)
Fixes #1097
Łukasz Langa [Mon, 28 Oct 2019 18:39:48 +0000 (19:39 +0100)]
Restore simple form of if statement
Łukasz Langa [Mon, 28 Oct 2019 16:44:30 +0000 (17:44 +0100)]
Simplify some code flow
Put empty lines after control flow changes.
Łukasz Langa [Mon, 28 Oct 2019 16:42:46 +0000 (17:42 +0100)]
Explicitly close .gitignore during processing
Łukasz Langa [Mon, 28 Oct 2019 16:35:33 +0000 (17:35 +0100)]
Remove unnecessary casts after pinning Mypy to >= 0.740
Łukasz Langa [Mon, 28 Oct 2019 16:09:25 +0000 (17:09 +0100)]
Use early returns in `get_grammars()` to save an indentation level
Łukasz Langa [Mon, 28 Oct 2019 14:31:37 +0000 (15:31 +0100)]
Reword comment
Jelle Zijlstra [Mon, 28 Oct 2019 14:25:42 +0000 (07:25 -0700)]
line_length=1 to reduce churn (#1092)
Łukasz Langa [Mon, 28 Oct 2019 13:53:25 +0000 (14:53 +0100)]
Fix regression: unexpected parentheses around non-mathematical powers
This was caused by an overly liberal application of parentheses in #909 that
fixed #646.
Fixes #1041
Joe Antonakakis [Mon, 28 Oct 2019 13:25:26 +0000 (06:25 -0700)]
Add diff support to blackd (#969)
Łukasz Langa [Mon, 28 Oct 2019 13:09:57 +0000 (14:09 +0100)]
Upgrade typed-ast to 1.4.0
Łukasz Langa [Mon, 28 Oct 2019 12:34:52 +0000 (13:34 +0100)]
Put missing contributors in the list (THANKS!)
Łukasz Langa [Mon, 28 Oct 2019 12:21:30 +0000 (13:21 +0100)]
Let readers know E203 and W503 are explained later
Łukasz Langa [Mon, 28 Oct 2019 12:12:58 +0000 (13:12 +0100)]
Put missing features and fixes in the change log
Łukasz Langa [Mon, 28 Oct 2019 12:00:31 +0000 (13:00 +0100)]
Docstring nit
Jelle Zijlstra [Sun, 27 Oct 2019 11:31:10 +0000 (04:31 -0700)]
fix crash with long type annotations (#1093)
Jelle Zijlstra [Sun, 27 Oct 2019 11:29:08 +0000 (04:29 -0700)]
coverage: omit tests/data (#1095)
Noticed that when it complains about falling coverage, it's sometimes because code in tests/data isn't executed.
Tzu-ping Chung [Thu, 24 Oct 2019 21:19:13 +0000 (05:19 +0800)]
Do not crash when failing to read an entry (#1090)
Michael McClimon [Thu, 24 Oct 2019 04:15:12 +0000 (00:15 -0400)]
setup.py: rename _version.py to _black_version.py (#1089)
In #1082, _version.py was renamed to _black_version.py, but the
py_modules line in setup.py wasn't changed, which meant that when
installed from source, running it failed with something like:
```
Traceback (most recent call last):
File "~/.pyenv/versions/3.6.5/bin/black", line 5, in <module>
from black import patched_main
File "~/.pyenv/versions/3.6.5/lib/python3.6/site-packages/black.py", line 55, in <module>
from _black_version import version as __version__
ModuleNotFoundError: No module named '_black_version'
```
Łukasz Langa [Mon, 21 Oct 2019 13:03:01 +0000 (15:03 +0200)]
s/_version.py/_black_version.py/ (#1082)
Some users are installing Black as a dependency in their project. Having
a _version.py in site-packages is asking for a conflict sooner or later.
Ideally we shouldn't require a separate version file at all, that's an
additional import we need to make. But I'll leave that bikeshedding for
a different time.
jgirardet [Mon, 21 Oct 2019 09:44:53 +0000 (11:44 +0200)]
add gitignore support using pathspec (#878)
Yngve Høiseth [Mon, 21 Oct 2019 09:42:46 +0000 (11:42 +0200)]
Automatic markdown and YAML formatting with Prettier (#874)
Alexander Huynh [Mon, 21 Oct 2019 09:21:05 +0000 (02:21 -0700)]
Restore all cursors, instead of only the current window (#978)
If we have the same buffer open in multiple windows/tabs, we'll only
restore the current window's cursor.
Iterate through all tabs and windows, and save/restore all cursor
positions of windows that contain our buffer.
Addendum to #433.
Matt VanEseltine [Mon, 21 Oct 2019 09:20:13 +0000 (05:20 -0400)]
Do not load incompatible cache (#875) (#1034)
A black cache created in Python 3.8 throws an unhandled
ValueError in earlier versions. This is because 3.6 does
not recognize the pickle protocol used as default in 3.8.
Accordingly, this commit:
- Fixes read_cache to return an empty cache instead.
- Changes the pickle protocol to 4 as the highest protocol
fully supported by black's supported Python versions.
Hugo van Kemenade [Mon, 21 Oct 2019 09:18:23 +0000 (12:18 +0300)]
Run pre-commit on Travis CI (#1081)
Łukasz Langa [Mon, 21 Oct 2019 09:16:34 +0000 (11:16 +0200)]
Revert "restore cursor to same line of code, not same line of buffer (#989)"
This reverts commit
65c5a0d9f180c4b36ea98917cb3b569f8e4f892f.
Edge cases were discovered on the pull request post merge.
Jelle Zijlstra [Sun, 20 Oct 2019 16:02:17 +0000 (09:02 -0700)]
Back out #850 (#1079)
Fixes #1042 (and probably #1044 which looks like the same thing).
The issue with the "obviously unnecessary" parentheses that #850 removed is that sometimes they're necessary to help Black fit something in one line. I didn't see an obvious solution that still removes the parens #850 was intended to remove, so let's back out this change for now in the interest of unblocking a release.
This PR also adds a test adapted from the failing example in #1042, so that if we try to reapply the #850 change we don't break the same case again.
Jelle Zijlstra [Sun, 20 Oct 2019 15:35:57 +0000 (08:35 -0700)]
fix CI (#1078)
Yurii Karabas [Sun, 20 Oct 2019 14:52:07 +0000 (17:52 +0300)]
Set correct return statement for `is_type_comment` function (#929)
Asger Hautop Drewsen [Sun, 20 Oct 2019 14:43:02 +0000 (16:43 +0200)]
Use better default venv dir when using neovim (#937)
Zsolt Dollenstein [Sun, 20 Oct 2019 14:30:44 +0000 (07:30 -0700)]
Create new issue templates (#934)
* Create new issue templates
* style -> design
* Apply suggestions from code review
Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
Andrew Thorp [Sun, 20 Oct 2019 14:26:17 +0000 (10:26 -0400)]
Update README.md (#906)
Add Kakoune integration instructions
Josh Bode [Sun, 20 Oct 2019 14:24:50 +0000 (16:24 +0200)]
Change how venv path is modified in vim plugin (#804)
- Check if black venv path is not already in `sys.path`
- Append (not insert) path so that black doesn't incorrectly import backports (e.g. `typing`)
Avoids this error if `typing` is present in venv:
```
Traceback (most recent call last):
File "<string>", line 56, in <module>
File "/home/josh/.virtualenvs/default/lib/python3.7/site-packages/black.py", line 19, in <module>
from typing import (
File "/home/josh/.virtualenvs/default/lib/python3.7/site-packages/typing.py", line 1356, in <module>
class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
File "/home/josh/.virtualenvs/default/lib/python3.7/site-packages/typing.py", line 1004, in __new__
self._abc_registry = extra._abc_registry
AttributeError: type object 'Callable' has no attribute '_abc_registry'
```
Joe Antonakakis [Sun, 20 Oct 2019 14:16:26 +0000 (07:16 -0700)]
Add .svn to default exclusion list (#965)
Augie Fackler [Sun, 20 Oct 2019 14:08:34 +0000 (10:08 -0400)]
Tweak collection literals to explode with trailing comma (#826)
Florent Thiery [Sun, 20 Oct 2019 14:07:07 +0000 (16:07 +0200)]
add instructions to Readme for installing vim plugin using vim native package loading, and how to map a key to run it manually (#944)
Charles Reid [Sun, 20 Oct 2019 14:00:48 +0000 (07:00 -0700)]
restore cursor to same line of code, not same line of buffer (#989)
Michael J. Sullivan [Sun, 20 Oct 2019 13:55:31 +0000 (06:55 -0700)]
Blacken .py files in blib2to3 (#1011)
* Blacken .py files in blib2to3
This is in preparation for adding type annotations to blib2to3 in
order to compiling it with mypyc (#1009, which I can rebase on top of
this).
To enforce that it stays blackened, I just cargo-culted the existing
test code used for validating formatting. It feels pretty clunky now,
though, so I can abstract the common logic out into a helper if that
seems better. (But error messages might be less clear then?)
* Tidy up the tests
Hugo van Kemenade [Tue, 15 Oct 2019 18:56:28 +0000 (21:56 +0300)]
Test on Python 3.8 final (#1070)
Hugo van Kemenade [Tue, 15 Oct 2019 17:08:44 +0000 (20:08 +0300)]
Declare support for Python 3.8 (#1069)
Michael J. Sullivan [Tue, 15 Oct 2019 01:15:18 +0000 (18:15 -0700)]
Fix type: ignore line breaking when there is a destructuring assignment (#1065)
It turns out we also need to handle invisible *left* parens added at
the *start* of a line. Refactor `contains_unsplittable_type_ignore` to
handle this more cleanly.
Michael J. Sullivan [Mon, 14 Oct 2019 19:30:58 +0000 (12:30 -0700)]
Update Pipfile.lock (#1062)
Michael J. Sullivan [Mon, 14 Oct 2019 19:30:37 +0000 (12:30 -0700)]
Add .eggs to .gitignore (#1063)
I don't know what .eggs is but it keeps showing up when I work on black
so...
Linus Groh [Sun, 13 Oct 2019 18:35:31 +0000 (20:35 +0200)]
Add black version header to blackd responses (#1046)
Zsolt Dollenstein [Sun, 13 Oct 2019 17:24:11 +0000 (10:24 -0700)]
Require regex version 2019.8
Andrey [Sun, 13 Oct 2019 17:21:15 +0000 (20:21 +0300)]
#455 Fix bug with tricky unicode symbols (#1047)
* add test for special unicode symbol which usual re can not process correctly
add regex lib which supports unicode 12.1.0 standard
replace re usage in project in favor to regex
* #455 fix dependency
Hugo van Kemenade [Fri, 11 Oct 2019 03:19:43 +0000 (06:19 +0300)]
Used by: add pandas and Pillow (#1057)
Michael J. Sullivan [Fri, 11 Oct 2019 01:25:33 +0000 (18:25 -0700)]
Fix missed cases in the `# type: ignore` logic (#1059)
In #1040 I had convinced myself that the type ignore logic didn't
need anything like the ignored_ids from the type comment logic, but I
was wrong, and we do.
We hit these cases in practice a bunch.
Michael J. Sullivan [Thu, 10 Oct 2019 18:50:51 +0000 (11:50 -0700)]
Fix issue with type comments on lines with trailing commas (#1058)
The code introduced in #1027 to detect whether a type comment appeared
after a regular comment in a Line would spuriously misfire when a leaf
was in the comments dict but had an empty list of comments. This can
occur as an artifact of how comments on trailing commas are handled,
it seems.
(This was discovered trying to test black out on mypy.)
Michael J. Sullivan [Thu, 3 Oct 2019 01:57:49 +0000 (18:57 -0700)]
Don't break long lines when `type: ignore` is present (#1040)
Fixes #997.
Michael J. Sullivan [Tue, 1 Oct 2019 22:30:51 +0000 (15:30 -0700)]
Fix typechecking under mypy 0.730 (#1039)
mypy 0.730 fixed a bug involving nonexistent attributes accessed on
modules, which caused an error since COLONEQUAL never got added to
token.pyi. Add it.
Zsolt Dollenstein [Wed, 18 Sep 2019 13:08:03 +0000 (14:08 +0100)]
fix environment for readthedocs
Zsolt Dollenstein [Wed, 18 Sep 2019 13:00:18 +0000 (14:00 +0100)]
fix doc generation
Zsolt Dollenstein [Wed, 18 Sep 2019 12:48:15 +0000 (13:48 +0100)]
Bump dependencies
vezeli [Wed, 18 Sep 2019 12:34:20 +0000 (14:34 +0200)]
Switch from versioneer to setuptools-scm (#1008)
Zsolt Dollenstein [Wed, 18 Sep 2019 12:33:14 +0000 (13:33 +0100)]
fix tests
Pablo Galindo [Wed, 18 Sep 2019 11:54:40 +0000 (12:54 +0100)]
Support PEP 572 in while statements (#1028)
Commit
d8fa8df0526de9c0968e0a3568008f58eae45364 added support for
parsing and formatting PEP572, but it missed the posibility to add
PEP572 syntax in while statements.
Michael J. Sullivan [Tue, 17 Sep 2019 20:40:03 +0000 (13:40 -0700)]
Don't allow type comments to be merged behind regular comments (#1027)
Type comments only apply if they are the first comment on the line,
which means that allowing them to be pushed behind a regular comment
when joining lines is a semantic change (and, indeed, one that black
catches and fails on).
Rishikesh Jha [Wed, 4 Sep 2019 11:51:33 +0000 (17:21 +0530)]
Print a separate message when there are no inputs given (#999)
Fixes #886.
vezeli [Wed, 4 Sep 2019 08:11:07 +0000 (10:11 +0200)]
Change variable in README according to the PEP8 (#1002)
* Change variable in README according to the PEP8
* Change variable in tests according to the PEP8
Joe Antonakakis [Fri, 23 Aug 2019 14:51:29 +0000 (07:51 -0700)]
Fix unstable formatting involving unwrapping multiple parentheses (#836) (#961)
This change also unwraps all unnecessary parentheses.
Zsolt Dollenstein [Wed, 21 Aug 2019 14:40:51 +0000 (16:40 +0200)]
fix doc generation
Zsolt Dollenstein [Wed, 21 Aug 2019 13:42:30 +0000 (15:42 +0200)]
use versioneer to manage __version__ (#981)
Zsolt Dollenstein [Tue, 13 Aug 2019 15:26:01 +0000 (17:26 +0200)]
[blackd] Support `py36`-style values in X-Python-Variant header (#979)
Zsolt Dollenstein [Mon, 5 Aug 2019 09:07:43 +0000 (10:07 +0100)]
Reraise exception in `skip_if_exception` decorator
Joe Antonakakis [Mon, 5 Aug 2019 09:06:12 +0000 (02:06 -0700)]
Fix async blackd tests which won't fail currently (#966)
Joe Antonakakis [Sun, 4 Aug 2019 09:03:19 +0000 (02:03 -0700)]
Fix unstable format involving backslash + whitespace at beginning of file (#948)
Joe Antonakakis [Sat, 3 Aug 2019 23:33:23 +0000 (16:33 -0700)]
Remove unnecessary if-statement in maybe_make_parens_invisible_in_atom (#964)
Zsolt Dollenstein [Sun, 28 Jul 2019 15:40:04 +0000 (16:40 +0100)]
appease flake8...
Zsolt Dollenstein [Sun, 28 Jul 2019 15:35:10 +0000 (16:35 +0100)]
skip tests touching aiohttp when known exception occurs
Zsolt Dollenstein [Sun, 28 Jul 2019 15:22:17 +0000 (16:22 +0100)]
add change log entry
Zsolt Dollenstein [Sun, 28 Jul 2019 15:17:33 +0000 (16:17 +0100)]
Support PEP-570 (positional only arguments) (#946)
Code using positional only arguments is considered >= 3.8
Zsolt Dollenstein [Sun, 28 Jul 2019 15:03:23 +0000 (16:03 +0100)]
Add support for walrus operator (#935)
* Parse `:=` properly
* never unwrap parenthesis around `:=`
* When checking for AST-equivalence, use `ast` instead of `typed-ast` when running on python >=3.8
* Assume code that uses `:=` is at least 3.8
Abdur-Rahmaan Janhangeer [Thu, 25 Jul 2019 07:19:30 +0000 (11:19 +0400)]
CONTRIBUTING.md - update Python version (#942)
Mariatta [Thu, 25 Jul 2019 01:09:55 +0000 (19:09 -0600)]
Fix Travis CI badge (#939)
It should point to travis-ci.com instead of .org
Asger Hautop Drewsen [Wed, 24 Jul 2019 16:54:05 +0000 (18:54 +0200)]
Change repo name to psf/black in README (#938)
Zsolt Dollenstein [Wed, 24 Jul 2019 08:49:33 +0000 (09:49 +0100)]
update Pipfile.lock to work with Py3.[78]
Note: had to pin `docutils==0.15` because of https://github.com/pypa/pipenv/issues/3865
Hugo van Kemenade [Tue, 23 Jul 2019 08:50:50 +0000 (11:50 +0300)]
python/black -> psf/black (#936)
Zsolt Dollenstein [Mon, 22 Jul 2019 20:41:45 +0000 (21:41 +0100)]
Hello github.com/psf!
Yurii Karabas [Tue, 16 Jul 2019 17:45:56 +0000 (20:45 +0300)]
Use nullcontext in case when lock is None. Shutdown pool after code formatting. (#928)
Min ho Kim [Mon, 1 Jul 2019 14:42:30 +0000 (00:42 +1000)]
Fix typo (#916)
Brandt Bucher [Sat, 29 Jun 2019 16:35:16 +0000 (09:35 -0700)]
Force parentheses between unary op and binary power. (#909)
Zsolt Dollenstein [Fri, 28 Jun 2019 16:31:54 +0000 (17:31 +0100)]
Fix docstring of schedule_formatting
Fixes #914.
Brandt Bucher [Tue, 25 Jun 2019 16:44:12 +0000 (09:44 -0700)]
Fix mypy errors. (#911)
Juan Luis Cano Rodríguez [Tue, 25 Jun 2019 14:27:02 +0000 (16:27 +0200)]
Ignore broken E203 (#910)
See https://github.com/python/black/issues/565
Adam Johnson [Sun, 16 Jun 2019 15:39:03 +0000 (16:39 +0100)]
Add W503 to default flake8 ignore list (#894)
W503 and W504 are mutually exclusive, to do with splitting binary operators across lines. Black reformats code according to W504, putting the operator on the start of the newline, therefore W503 needs to be ignored in the suggested Flake8 config to use with Black.
Zsolt Dollenstein [Sat, 15 Jun 2019 06:36:34 +0000 (07:36 +0100)]
add change log entry
Zsolt Dollenstein [Sat, 15 Jun 2019 06:29:09 +0000 (07:29 +0100)]
Pin comment to single leaf in invisible parens (#872)