]> git.madduck.net Git - etc/vim.git/log

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:

etc/vim.git
2 years agoDrop upper version bounds on dependencies (GH-2718)
Jelle Zijlstra [Thu, 30 Dec 2021 21:17:11 +0000 (22:17 +0100)]
Drop upper version bounds on dependencies (GH-2718)

They mostly cause unnecessary trouble.

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agoSupport pytest 7 by fixing broken imports (GH-2705)
Miro Hrončok [Sat, 25 Dec 2021 03:28:43 +0000 (04:28 +0100)]
Support pytest 7 by fixing broken imports (GH-2705)

The tmp_path related changes are not necessary to make pytest 7 work,
but it feels more complete this way.

2 years agoremove all type: ignores in src/black (GH-2720)
Marco Edward Gorelli [Sat, 25 Dec 2021 02:25:03 +0000 (02:25 +0000)]
remove all type: ignores in src/black (GH-2720)

Excet
;t

2 years agoUpdate contributing wording (#2719)
Felix Hildén [Tue, 21 Dec 2021 18:43:10 +0000 (20:43 +0200)]
Update contributing wording (#2719)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agoSupport multiple top-level as-expressions on case statements (#2716)
Batuhan Taskaya [Tue, 21 Dec 2021 18:16:55 +0000 (21:16 +0300)]
Support multiple top-level as-expressions on case statements (#2716)

2 years agoRemove usage of Pipenv, rely on good ol' `pip` and `virtualenv` in docs (#2717)
Łukasz Langa [Tue, 21 Dec 2021 16:24:20 +0000 (17:24 +0100)]
Remove usage of Pipenv, rely on good ol' `pip` and `virtualenv` in docs (#2717)

2 years agoDefine is_name_token (and friends) to resolve some `type: ignore`s (GH-2714)
Marco Edward Gorelli [Tue, 21 Dec 2021 16:20:55 +0000 (16:20 +0000)]
Define is_name_token (and friends) to resolve some `type: ignore`s (GH-2714)

Gets rid of a few # type: ignores by using TypeGuard.

2 years agoDisable universal newlines when reading TOML (#2408)
Taneli Hukkinen [Tue, 21 Dec 2021 16:03:07 +0000 (18:03 +0200)]
Disable universal newlines when reading TOML (#2408)

2 years agoBump myst-parser from 0.16.0 to 0.16.1 in /docs (#2710)
dependabot[bot] [Mon, 20 Dec 2021 15:42:03 +0000 (07:42 -0800)]
Bump myst-parser from 0.16.0 to 0.16.1 in /docs (#2710)

Bumps [myst-parser](https://github.com/executablebooks/MyST-Parser) from 0.16.0 to 0.16.1.
- [Release notes](https://github.com/executablebooks/MyST-Parser/releases)
- [Changelog](https://github.com/executablebooks/MyST-Parser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/executablebooks/MyST-Parser/compare/v0.16.0...v0.16.1)

---
updated-dependencies:
- dependency-name: myst-parser
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoBump sphinx from 4.3.1 to 4.3.2 in /docs (#2709)
dependabot[bot] [Mon, 20 Dec 2021 15:24:53 +0000 (07:24 -0800)]
Bump sphinx from 4.3.1 to 4.3.2 in /docs (#2709)

Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 4.3.1 to 4.3.2.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/4.x/CHANGES)
- [Commits](https://github.com/sphinx-doc/sphinx/compare/v4.3.1...v4.3.2)

---
updated-dependencies:
- dependency-name: sphinx
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoImply 3.8+ when annotated assigments used with unparenthesized tuples (#2708)
Batuhan Taskaya [Fri, 17 Dec 2021 21:43:14 +0000 (00:43 +0300)]
Imply 3.8+ when annotated assigments used with unparenthesized tuples (#2708)

2 years agoUse 'python -m build' to build wheel and source distributions (#2701)
Mike Taves [Thu, 16 Dec 2021 03:35:01 +0000 (16:35 +1300)]
Use 'python -m build' to build wheel and source distributions (#2701)

2 years agoUnpacking on flow constructs (return/yield) now implies 3.8+ (#2700)
Batuhan Taskaya [Thu, 16 Dec 2021 00:17:33 +0000 (03:17 +0300)]
Unpacking on flow constructs (return/yield) now implies 3.8+ (#2700)

2 years agoBump pre-commit/action from 2.0.2 to 2.0.3 (GH-2695)
dependabot[bot] [Wed, 15 Dec 2021 23:55:26 +0000 (18:55 -0500)]
Bump pre-commit/action from 2.0.2 to 2.0.3 (GH-2695)

Bumps [pre-commit/action](https://github.com/pre-commit/action) from 2.0.2 to 2.0.3.
- [Release notes](https://github.com/pre-commit/action/releases)
- [Commits](https://github.com/pre-commit/action/compare/v2.0.2...v2.0.3)

---
updated-dependencies:
- dependency-name: pre-commit/action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoBump myst-parser from 0.15.2 to 0.16.0 in /docs (GH-2696)
dependabot[bot] [Wed, 15 Dec 2021 23:26:01 +0000 (18:26 -0500)]
Bump myst-parser from 0.15.2 to 0.16.0 in /docs (GH-2696)

Bumps [myst-parser](https://github.com/executablebooks/MyST-Parser) from 0.15.2 to 0.16.0.
- [Release notes](https://github.com/executablebooks/MyST-Parser/releases)
- [Changelog](https://github.com/executablebooks/MyST-Parser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/executablebooks/MyST-Parser/compare/v0.15.2...v0.16.0)

---
updated-dependencies:
- dependency-name: myst-parser
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoInclude underlying error when AST safety check parsing fails (#2693)
Richard Si [Wed, 15 Dec 2021 02:21:28 +0000 (21:21 -0500)]
Include underlying error when AST safety check parsing fails (#2693)

2 years agouse valid package-ecosystem key (#2694)
aru [Wed, 15 Dec 2021 02:21:15 +0000 (21:21 -0500)]
use valid package-ecosystem key (#2694)

2 years agochore: dump docs deps and pre-commit hooks (#2676)
Richard Si [Wed, 15 Dec 2021 01:25:47 +0000 (20:25 -0500)]
chore: dump docs deps and pre-commit hooks (#2676)

2 years agoDon't colour diff headers white, only bold (GH-2691)
Richard Si [Wed, 15 Dec 2021 00:32:14 +0000 (19:32 -0500)]
Don't colour diff headers white, only bold (GH-2691)

So people with light themed terminals can still read 'em.

2 years ago`from __future__ import annotations` now implies 3.7+ (#2690)
Batuhan Taskaya [Tue, 14 Dec 2021 23:22:56 +0000 (02:22 +0300)]
`from __future__ import annotations` now implies 3.7+ (#2690)

2 years agoSupport as-expressions on dict items (GH-2686)
Batuhan Taskaya [Sun, 12 Dec 2021 21:10:22 +0000 (00:10 +0300)]
Support as-expressions on dict items (GH-2686)

2 years agoShow details when a regex fails to compile (GH-2678)
Jelle Zijlstra [Wed, 8 Dec 2021 03:13:05 +0000 (19:13 -0800)]
Show details when a regex fails to compile (GH-2678)

2 years agono longer expect changes on pyanalyze (#2674)
Jelle Zijlstra [Sun, 5 Dec 2021 23:47:53 +0000 (15:47 -0800)]
no longer expect changes on pyanalyze (#2674)

https://github.com/quora/pyanalyze/pull/316

2 years agoPrepare for release 21.12b0 (GH-2673)
Richard Si [Sun, 5 Dec 2021 21:39:34 +0000 (16:39 -0500)]
Prepare for release 21.12b0 (GH-2673)

Let's do this!

2 years agoperf: drop the initial stack copy (#2670)
Batuhan Taskaya [Sun, 5 Dec 2021 21:03:48 +0000 (00:03 +0300)]
perf: drop the initial stack copy (#2670)

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agoblib2to3 can raise TokenError and IndentationError too (#2671)
Richard Si [Sun, 5 Dec 2021 16:53:58 +0000 (11:53 -0500)]
blib2to3 can raise TokenError and IndentationError too (#2671)

2 years agoReorganize changelog (#2669)
Jelle Zijlstra [Sat, 4 Dec 2021 23:57:40 +0000 (15:57 -0800)]
Reorganize changelog (#2669)

I believe it would be useful to split up the long list of changes a bit more.

Specific changes:
- Removed the entry for new flake8 plugins; this is purely internal and not of interest to users
- Put regex in the packaging section
- New section for Jupyter Notebook
- New section for Python 3.10, mostly match/case stuff

2 years agotell users to use -t py310 (#2668)
Jelle Zijlstra [Sat, 4 Dec 2021 23:30:23 +0000 (15:30 -0800)]
tell users to use -t py310 (#2668)

2 years agoDon't let TokenError bubble up from lib2to3_parse (GH-2343)
Tanvi Moharir [Sat, 4 Dec 2021 20:21:26 +0000 (01:51 +0530)]
Don't let TokenError bubble up from lib2to3_parse (GH-2343)

error: cannot format <string>: ('EOF in multi-line statement', (2, 0))

 ▲ before ▼ after

error: cannot format <string>: Cannot parse: 2:0: EOF in multi-line statement

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agoMake star-expression spacing consistent in match/case (#2667)
Batuhan Taskaya [Fri, 3 Dec 2021 14:49:33 +0000 (17:49 +0300)]
Make star-expression spacing consistent in match/case (#2667)

2 years agoRemove regex dependency (GH-2663)
Jelle Zijlstra [Thu, 2 Dec 2021 22:35:02 +0000 (14:35 -0800)]
Remove regex dependency (GH-2663)

We were no longer using it since GH-2644 and GH-2654. This should hopefully
make using Black easier to use as there's one less compiled dependency.
The core team also doesn't have to deal with the surprisingly frequent fires
the regex packaging setup goes through.

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agoEnsure match/case are recognized as statements (#2665)
Batuhan Taskaya [Thu, 2 Dec 2021 17:58:22 +0000 (20:58 +0300)]
Ensure match/case are recognized as statements (#2665)

2 years agoTreat functions/classes in blocks as if they're nested (GH-2472)
Richard Si [Wed, 1 Dec 2021 23:05:59 +0000 (18:05 -0500)]
Treat functions/classes in blocks as if they're nested (GH-2472)

* Treat functions/classes in blocks as if they're nested

One curveball is that we still want two preceding newlines before blocks
that are probably logically disconnected. In other words:

    if condition:

        def foo():
            return "hi"
                             # <- aside: this is the goal of this commit
    else:

        def foo():
            return "cya"
                             # <- the two newlines spacing here should stay
                             #    since this probably isn't related
    with open("db.json", encoding="utf-8") as f:
        data = f.read()

Unfortunately that means we have to special case specific clause types
instead of just being able to just for a colon leaf. The hack used here
is to check whether we're adding preceding newlines for a standalone or
dependent clause. "Standalone" being a clause that doesn't need another
clause to be valid (eg. if) and vice versa.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2 years agoslightly better example link (#2617)
Jelle Zijlstra [Wed, 1 Dec 2021 21:47:33 +0000 (13:47 -0800)]
slightly better example link (#2617)

Since we also need to update two places in the docs

2 years agoFix determination of f-string expression spans (#2654)
Shantanu [Wed, 1 Dec 2021 17:52:24 +0000 (09:52 -0800)]
Fix determination of f-string expression spans (#2654)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2 years agofix error message for match (#2649)
Jelle Zijlstra [Wed, 1 Dec 2021 02:39:39 +0000 (18:39 -0800)]
fix error message for match (#2649)

Fixes #2648.

Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
2 years agoReduce usage of regex (#2644)
Jelle Zijlstra [Wed, 1 Dec 2021 02:01:36 +0000 (18:01 -0800)]
Reduce usage of regex (#2644)

This removes all but one usage of the `regex` dependency. Tricky bits included:
- A bug in test_black.py where we were incorrectly using a character range. Fix also submitted separately in #2643.
- `tokenize.py` was the original use case for regex (#1047). The important bit is that we rely on `\w` to match anything valid in an identifier, and `re` fails to match a few characters as part of identifiers. My solution is to instead match all characters *except* those we know to mean something else in Python: whitespace and ASCII punctuation. This will make Black able to parse some invalid Python programs, like those that contain non-ASCII punctuation in the place of an identifier, but that seems fine to me.
- One import of `regex` remains, in `trans.py`. We use a recursive regex to parse f-strings, and only `regex` supports that. I haven't thought of a better fix there (except maybe writing a manual parser), so I'm leaving that for now.

My goal is to remove the `regex` dependency to reduce the risk of breakage due to dependencies and make life easier for users on platforms without wheels.

2 years agoFix line generation for `match match:` / `case case:` (GH-2661)
Batuhan Taskaya [Tue, 30 Nov 2021 20:56:38 +0000 (23:56 +0300)]
Fix line generation for `match match:` / `case case:` (GH-2661)

2 years agoadd FAQ entry about undetected syntax errors (#2645)
Jelle Zijlstra [Tue, 30 Nov 2021 20:34:45 +0000 (12:34 -0800)]
add FAQ entry about undetected syntax errors (#2645)

This came up in #2644.

2 years agoRemove hidden import from PyInstaller build (#2657)
Jameel Al-Aziz [Tue, 30 Nov 2021 16:20:27 +0000 (08:20 -0800)]
Remove hidden import from PyInstaller build (#2657)

The recent 2021.4 release of pyinstaller-hooks-contrib now contains a
built-in hook for platformdirs. Manually specifying the hidden import
arg should no longer be needed.

2 years agoAllow top-level starred expression on match (#2659)
Batuhan Taskaya [Tue, 30 Nov 2021 15:52:25 +0000 (18:52 +0300)]
Allow top-level starred expression on match (#2659)

Fixes #2647

2 years agoReturn `NothingChanged` if non-Python cell magic is detected, to avoid tokenize error...
Daniel Sparing [Mon, 29 Nov 2021 23:07:35 +0000 (18:07 -0500)]
Return `NothingChanged` if non-Python cell magic is detected, to avoid tokenize error (#2630)

Fixes https://github.com/psf/black/issues/2627 , a non-Python cell magic such as `%%writeline` can legitimately contain "incorrect" indentation, however this causes `tokenize-rt` to return an error. To avoid this, `validate_cell` should early detect cell magics (just like it detects `TransformerManager` transformations).

Test added too, in the shape of a "badly indented" `%%writefile` within `test_non_python_magics`.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Marco Edward Gorelli <marcogorelli@protonmail.com>
2 years agoadd more flake8 lints (#2653)
danieleades [Mon, 29 Nov 2021 02:20:52 +0000 (02:20 +0000)]
add more flake8 lints (#2653)

2 years agoadd missing f-string (#2650)
Marco Edward Gorelli [Sat, 27 Nov 2021 02:53:16 +0000 (02:53 +0000)]
add missing f-string (#2650)

2 years ago Assignment to env var in Jupyter Notebook doesn't round-trip (#2642)
Marco Edward Gorelli [Fri, 26 Nov 2021 16:14:57 +0000 (16:14 +0000)]
 Assignment to env var in Jupyter Notebook doesn't round-trip (#2642)

closes #2641

2 years agofix regex (#2643)
Jelle Zijlstra [Fri, 26 Nov 2021 02:34:19 +0000 (18:34 -0800)]
fix regex (#2643)

2 years agoREADME: Add KeepTruckin to the list of orgs (GH-2638)
Wael Nasreddine [Fri, 26 Nov 2021 01:09:47 +0000 (17:09 -0800)]
README: Add KeepTruckin to the list of orgs (GH-2638)

At KT, we used Black to format all Python code in our Mono-repo.

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2 years agogrammar: accept open sequences on match subject (GH-2639)
Batuhan Taskaya [Thu, 25 Nov 2021 01:21:36 +0000 (04:21 +0300)]
grammar: accept open sequences on match subject (GH-2639)

* grammar: accept open sequences on match subject
* give an example about the fixed match subject

3 years agoChange `cfg` to `ini` for text highlighting (#2632)
Ash [Sun, 21 Nov 2021 15:02:08 +0000 (15:02 +0000)]
Change `cfg` to `ini` for text highlighting (#2632)

3 years agoFix process pool fallback on Python 3.10 (GH-2631)
Matthew D. Scholefield [Sat, 20 Nov 2021 19:25:30 +0000 (11:25 -0800)]
Fix process pool fallback on Python 3.10 (GH-2631)

In Python 3.10 the exception generated by creating a process pool on
a Python build that doesn't support this is now `NotImplementedError`

Commit history before merge:

* Fix process pool fallback on Python 3.10
* Update CHANGES.md
* Update CHANGES.md

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
3 years agoFix mypyc compat issue w/ AST safety check (GH-2628)
Richard Si [Fri, 19 Nov 2021 03:20:44 +0000 (22:20 -0500)]
Fix mypyc compat issue w/ AST safety check (GH-2628)

I can't wait for when we drop Python 2 support FWIW :)

3 years agoprepare release 2021.11b1 (#2622)
Jelle Zijlstra [Thu, 18 Nov 2021 03:51:49 +0000 (19:51 -0800)]
prepare release 2021.11b1 (#2622)

3 years agoBump regex dependency to 2021.4.4 to fix import of Pattern class (#2621)
Rowan Seymour [Thu, 18 Nov 2021 03:46:28 +0000 (22:46 -0500)]
Bump regex dependency to 2021.4.4 to fix import of Pattern class (#2621)

Fixes #2620

3 years agoprepare release 21.11b0 (#2616)
Jelle Zijlstra [Wed, 17 Nov 2021 02:30:19 +0000 (18:30 -0800)]
prepare release 21.11b0 (#2616)

3 years agofix vim plugin (#2615)
Jelle Zijlstra [Wed, 17 Nov 2021 02:22:32 +0000 (18:22 -0800)]
fix vim plugin (#2615)

3 years agoFix 3.10's supported features (#2614)
Richard Si [Tue, 16 Nov 2021 05:07:25 +0000 (00:07 -0500)]
Fix 3.10's supported features (#2614)

3 years agoImplementing mypyc support pt. 2 (#2431)
Richard Si [Tue, 16 Nov 2021 04:24:16 +0000 (23:24 -0500)]
Implementing mypyc support pt. 2  (#2431)

3 years agovim: Parse skip_magic_trailing_comma from pyproject.toml (#2613)
Jelle Zijlstra [Tue, 16 Nov 2021 03:03:47 +0000 (19:03 -0800)]
vim: Parse skip_magic_trailing_comma from pyproject.toml (#2613)

Co-authored-by: Kyle Kovacs <kkovacs@diconfiberoptics.com>
3 years agoDocker image usage description (#2412)
pszlazak [Tue, 16 Nov 2021 02:47:21 +0000 (03:47 +0100)]
Docker image usage description (#2412)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
3 years agoblack/parser: optimize deepcopying nodes (#2611)
Batuhan Taskaya [Tue, 16 Nov 2021 02:38:40 +0000 (05:38 +0300)]
black/parser: optimize deepcopying nodes (#2611)

The implementation of the new backtracking logic depends heavily on deepcopying the current state of the parser before seeing one of the new keywords, which by default is an very expensive operations. On my system, formatting these 3 files takes 1.3 seconds.

```
 $ touch tests/data/pattern_matching_*; time python -m black -tpy310 tests/data/pattern_matching_*             19ms
All done! ✨ 🍰 ✨
3 files left unchanged.
python -m black -tpy310 tests/data/pattern_matching_*  2,09s user 0,04s system 157% cpu 1,357 total
```

which can be optimized 3X if we integrate the existing copying logic (`clone`) to the deepcopy system;
```
 $ touch tests/data/pattern_matching_*; time python -m black -tpy310 tests/data/pattern_matching_*              1ms
All done! ✨ 🍰 ✨
3 files left unchanged.
python -m black -tpy310 tests/data/pattern_matching_*  0,66s user 0,02s system 147% cpu 0,464 total
```

This still might have some potential, but that would be way trickier than this initial patch.

3 years agoRemoved distutils import from autoload/black.vim (#2607) (#2610)
Michal Siska [Mon, 15 Nov 2021 16:51:56 +0000 (17:51 +0100)]
Removed distutils import from autoload/black.vim (#2607) (#2610)

3 years agoDeclare support for Python 3.10 (#2562)
Hugo van Kemenade [Sun, 14 Nov 2021 14:37:06 +0000 (16:37 +0200)]
Declare support for Python 3.10 (#2562)

3 years agoblack/parser: support as-exprs within call args (#2608)
Batuhan Taskaya [Sun, 14 Nov 2021 14:04:31 +0000 (17:04 +0300)]
black/parser: support as-exprs within call args (#2608)

3 years agoAllow install under pypy (#2559)
Oliver Margetts [Sun, 14 Nov 2021 03:46:15 +0000 (03:46 +0000)]
Allow install under pypy (#2559)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
3 years agoblack/parser: partial support for pattern matching (#2586)
Batuhan Taskaya [Sun, 14 Nov 2021 03:15:31 +0000 (06:15 +0300)]
black/parser: partial support for pattern matching (#2586)

Partial implementation for #2242. Only works when explicitly stated -t py310.

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
3 years agoBump deps in Pipfile.lock (GH-2605)
Richard Si [Sat, 13 Nov 2021 01:41:46 +0000 (20:41 -0500)]
Bump deps in Pipfile.lock (GH-2605)

Mostly because the hashes for typed-ast were valid for 1.4.2 when the
version is pinned to 1.4.3 ... pipenv is pleasant to use /s

3 years agoFix typos (#2603)
Kian Meng Ang [Fri, 12 Nov 2021 03:02:43 +0000 (11:02 +0800)]
Fix typos (#2603)

3 years agoImprove Python 2 only syntax detection (GH-2592)
Richard Si [Fri, 12 Nov 2021 01:28:48 +0000 (20:28 -0500)]
Improve Python 2 only syntax detection (GH-2592)

* Improve Python 2 only syntax detection

First of all this fixes a mistake I made in Python 2 deprecation PR
using token.* to check for print/exec statements. Turns out that
for nodes with a type value higher than 256 its numeric type isn't
guaranteed to be constant. Using syms.* instead fixes this.

Also add support for the following cases:

    print "hello, world!"

    exec "print('hello, world!')"

    def set_position((x, y), value):
        pass

    try:
        pass
    except Exception, err:
        pass

    raise RuntimeError, "I feel like crashing today :p"

    `wow_these_really_did_exist`

    10L

* Add octal support, more test cases, and fixup long ints

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
3 years agoprimer: Hypothesis now requires Python>=3.8 (GH-2602)
Richard Si [Thu, 11 Nov 2021 22:52:13 +0000 (17:52 -0500)]
primer: Hypothesis now requires Python>=3.8 (GH-2602)

looks like their project dev tooling uses some newer syntax or something

3 years agoAdd a missing space in Python 2 deprecation (GH-2590)
LordOfPolls [Sat, 6 Nov 2021 16:04:27 +0000 (16:04 +0000)]
Add a missing space in Python 2 deprecation (GH-2590)

`DEPRECATION: Python 2 support will be removed in the first stable releaseexpected in January 2022` - > `DEPRECATION: Python 2 support will be removed in the first stable release expected in January 2022`

3 years agoUpdate CHANGES.md for 21.10b0 release (#2583)
Cooper Lees [Mon, 1 Nov 2021 00:59:39 +0000 (17:59 -0700)]
Update CHANGES.md for 21.10b0 release (#2583)

* Update CHANGES.md for 21.10b0 release

* Update version in docs/usage_and_configuration/the_basics.md

* Also update docs/integrations/source_version_control.md ...

3 years ago install build-essential to compile dependencies and use multi-stage build (#2582)
Vincent Barbaresi [Mon, 1 Nov 2021 00:43:34 +0000 (01:43 +0100)]
 install build-essential to compile dependencies and use multi-stage build  (#2582)

- Install build-essential to avoid build issues like #2568 when dependencies don't have prebuilt wheels available
- Use multi-stage build instead of trying to purge packages and cache from the image
  Copying `/root/.local/` installs only black's built Python dependencies (< 20 MB).
  So the image is barely larger than python:3-slim base image

3 years agoDeprecate Python 2 formatting support (#2523)
Richard Si [Sun, 31 Oct 2021 23:46:12 +0000 (19:46 -0400)]
Deprecate Python 2 formatting support (#2523)

* Prepare for Python 2 depreciation

- Use BlackRunner and .stdout in command line test

So the next commit won't break this test. This is in its own commit so
we can just revert the depreciation commit when dropping Python 2
support completely.

* Deprecate Python 2 formatting support

3 years agoPin regex in docker to 2021.10.8 (GH-2579)
Cooper Lees [Sun, 31 Oct 2021 17:41:12 +0000 (10:41 -0700)]
Pin regex in docker to 2021.10.8 (GH-2579)

* Pin regex in docker to 2021.10.8
- This is due to 2021.10.8 having arm wheels and newer versions not

I will go see if I can help restore arm build @ https://bitbucket.org/mrabarnett/mrab-regex/issues/399/missing-wheel-for-macosx-and-the-new-m1 soon.

Test: Build on my M1 mac: `docker build -t cooperlees/black .`

* Add in that the pin is only for docker

3 years agoAddress mypy errors on 3.10 w/ asyncio loop parameter (#2580)
Richard Si [Sat, 30 Oct 2021 22:35:55 +0000 (18:35 -0400)]
Address mypy errors on 3.10 w/ asyncio loop parameter (#2580)

3 years agoUpdate bug template (#2538)
Felix Hildén [Sat, 30 Oct 2021 22:01:40 +0000 (01:01 +0300)]
Update bug template (#2538)

3 years agoUse STDIN project in test_projects to ensure it runs quickly (#2575)
Nipunn Koorapati [Sat, 30 Oct 2021 18:54:43 +0000 (11:54 -0700)]
Use STDIN project in test_projects to ensure it runs quickly (#2575)

Existing test was actually running a full black-primer
run which could be slow. This goes from 8 seconds to
0.4 seconds on my machine.

Needed to move to top level scope to leverage the caplog
feature of pytest in order to test that the command line
was parsing the bogus arguments and dumping to stderr.

3 years agoAdd Tesla to organizations list (#2577)
Roma [Sat, 30 Oct 2021 18:45:09 +0000 (11:45 -0700)]
Add Tesla to organizations list (#2577)

3 years agofix: allow tests to be run from (hopefully) any directory (GH-2574)
dawn [Sat, 30 Oct 2021 15:50:45 +0000 (11:50 -0400)]
fix: allow tests to be run from (hopefully) any directory (GH-2574)

* fix: allow tests to be run from the tests/ directory
* fix: try fixing windows build with MarcoGorelli's suggestion
* Windows hotfix + better respect test's spirit

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
3 years agoblack-primer: Print summary after individual failures (#2570)
Nipunn Koorapati [Thu, 28 Oct 2021 17:35:37 +0000 (10:35 -0700)]
black-primer: Print summary after individual failures (#2570)

If the individual failures are verbose, it's useful to have
the summary at the end. Otherwise, it can be really difficult
to figure out which projects have an issue.

3 years agoAdd --projects cli flag to black-primer (#2555)
Nipunn Koorapati [Wed, 27 Oct 2021 18:31:34 +0000 (11:31 -0700)]
Add --projects cli flag to black-primer (#2555)

* Add --projects cli flag to black-primer

Makes it possible to run a subset of projects on black primer

* Refactor into click callback

3 years agoPrint out line diff on test failure (#2552)
Nipunn Koorapati [Wed, 27 Oct 2021 14:37:20 +0000 (07:37 -0700)]
Print out line diff on test failure (#2552)

It currently prints both ASTs - this also
adds the line diff, making it much easier to visualize
the changes as well. Not too verbose since it's only a diff.

3 years agoRefactor Jupyter magic handling (#2545)
Marco Edward Gorelli [Wed, 27 Oct 2021 14:36:10 +0000 (15:36 +0100)]
Refactor Jupyter magic handling (#2545)

3 years agoRemove some unneeded exceptions from mypy.ini (#2557)
Nipunn Koorapati [Fri, 22 Oct 2021 03:59:48 +0000 (20:59 -0700)]
Remove some unneeded exceptions from mypy.ini (#2557)

3 years agoDisallow any Generics on mypy except in black_primer (#2556)
Nipunn Koorapati [Fri, 22 Oct 2021 02:38:39 +0000 (19:38 -0700)]
Disallow any Generics on mypy except in black_primer (#2556)

Only black_primer needs the disallowal - means we'll
get better typing everywhere else.

3 years agoDefine a stability policy (#2529)
Jelle Zijlstra [Thu, 21 Oct 2021 15:02:38 +0000 (08:02 -0700)]
Define a stability policy (#2529)

Fixes #2394. Eventually fixes #517.

This is essentially @pradyunsg's suggestion from #2394. I suggest that at the
same time we start the formal stability policy, we take a few other disruptive steps
and drop Python 2 and the "b" marker.

Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
3 years agobump sphinx so it works on Python3.10 (#2546)
Marco Edward Gorelli [Tue, 19 Oct 2021 17:52:10 +0000 (18:52 +0100)]
bump sphinx so it works on Python3.10 (#2546)

3 years agoFix feature detection for positional-only arguments in lambdas (#2532)
Zac Hatfield-Dodds [Tue, 12 Oct 2021 04:45:58 +0000 (15:45 +1100)]
Fix feature detection for positional-only arguments in lambdas (#2532)

3 years agochore(ci): use official Python 3.10 (#2521)
Mathieu Kniewallner [Tue, 5 Oct 2021 21:22:56 +0000 (23:22 +0200)]
chore(ci): use official Python 3.10 (#2521)

Python 3.10 (final) was released yesterday and is now available on GHA!

3 years agoBump typed-ast minimum to 1.4.3 for 3.10 compat (#2519)
Richard Si [Tue, 5 Oct 2021 00:36:57 +0000 (20:36 -0400)]
Bump typed-ast minimum to 1.4.3 for 3.10 compat (#2519)

3 years agoMNT: remove unnecessary test deps + some refactoring (GH-2510)
Richard Si [Sat, 2 Oct 2021 23:37:32 +0000 (19:37 -0400)]
MNT: remove unnecessary test deps + some refactoring (GH-2510)

The main goals of this commit include:

* improving consistency on how strict the test suite is -- Jelle has
  seen cases where a test did not fail to an incomplete test setup
  even though it should've
* simplifying tests for both ease of creation and reading via
  parametrization and helpers
* reorganizing the test suite by grouping more tests
* dropping test suite dependencies that aren't strictly necessary

The test suite could definitely do with more refactoring, but this is a
good first pass. Anyway it would've gotten too big to review effectively
if I did continue on this PR.

Commit history before squash merge:

* Drop parameterized dep and refactor format tests

Since the test suite is already using pytest-only features we can drop
the parameterized test dependency in favour of pytest's own offering.

I also added an utility function called assert_format that makes it
even easier to verify Black formats some code correctly. We already
have great tooling if the case is very simple in test_format.py but
any sort of complication makes it hard to use. Also if you're writing
a non-standard test case, you have to be careful to include all of
the steps so issues don't go undetected. assert_format aims to
1) improve consistency, 2) avoid wasted CPU cycles, and 3) avoid
logical errors that hide issues.

Finally, quite a few tests were either moved and/or simplified with
the new setup.

* Move file collection tests
* Add assert_collected_sources helper function

Testing source collection involves a lot of repetitive boilerplate,
something that black.files.get_sources's signature does not help with.
So to cut down on boilerplate like `report=black.Report()` I added
a convenience function to tests/test_black.py which wraps
black.get_sources. Its signature is designed to be much more lax to
make it much easier to use. Somehow this leads to cutting 100 lines!

Also IMO the test cases are much easier to read since it's more
declarative than really procedural now.

* Run isort on some test files
* Move cache tests
* Use pytest-style asserts & add parametrization
* Drop now unnecessary test dependencies

*pytest-cases might be interesting for further refactoring but I
haven't been able to wrap my head around it for the time being. We
can always revisit anyway.

3 years agoAdd --workers CLI parameter (fixes #2513) (#2514)
Fergus Mitchell [Wed, 29 Sep 2021 16:50:44 +0000 (17:50 +0100)]
Add --workers CLI parameter (fixes #2513) (#2514)

Fixes #2513

3 years agoAllow to pass the FileMode options in the vim plugin (#1319)
shaoran [Wed, 29 Sep 2021 00:31:29 +0000 (02:31 +0200)]
Allow to pass the FileMode options in the vim plugin (#1319)

3 years agoFix python_version markers in Pipfile.lock (#2511)
Richard Si [Tue, 28 Sep 2021 22:41:35 +0000 (18:41 -0400)]
Fix python_version markers in Pipfile.lock (#2511)

This took way too much effort but in the end I was able to achieve a
(mostly) functional Pipfile.lock ranging from 3.6 to 3.9 🎉

3 years agoAdd test to cover when unable to replace magics (#2471)
Marco Edward Gorelli [Sat, 25 Sep 2021 19:46:36 +0000 (20:46 +0100)]
Add test to cover when unable to replace magics (#2471)

Another follow-up from #2357, adding a test for uncovered code.

3 years agoBump required aiohttp version to 3.7.4 (#2509)
Zsolt Dollenstein [Sat, 25 Sep 2021 19:45:13 +0000 (20:45 +0100)]
Bump required aiohttp version to 3.7.4 (#2509)

Commit history before merge:

* Bump required aiohttp version to 3.7.4

This release includes an important security fix
(https://github.com/aio-libs/aiohttp/security/advisories/GHSA-v6wp-4m6f-gcjg) and many
other improvements.

* add changelog entry
* Let's not forget about Pipfile

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
3 years agore-implement simple CORS middleware for blackd (#2500)
Zsolt Dollenstein [Sat, 25 Sep 2021 11:58:44 +0000 (12:58 +0100)]
re-implement simple CORS middleware for blackd (#2500)

* re-implement simple CORS middleware for blackd
* remove aiohttp-cors from setup.py
* Remove aiohttp-cors from Pipfile.lock

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
3 years agoAdd Kedro to project list and QuantumBlack to orgs (#2502)
Deepyaman Datta [Fri, 24 Sep 2021 02:20:48 +0000 (22:20 -0400)]
Add Kedro to project list and QuantumBlack to orgs (#2502)

3 years agoDOC: cleanup pre-commit instructions following #2430 (#2481)
Clément Robert [Sun, 19 Sep 2021 09:15:39 +0000 (11:15 +0200)]
DOC: cleanup pre-commit instructions following #2430 (#2481)

3 years agoadd check for version in the-basics example (#2459)
Marco Edward Gorelli [Sun, 19 Sep 2021 03:24:09 +0000 (04:24 +0100)]
add check for version in the-basics example (#2459)