Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove regex dependency #2663

Merged
merged 6 commits into from Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -4,6 +4,7 @@

### _Black_

- Remove dependency on `regex` (#2663)
JelleZijlstra marked this conversation as resolved.
Show resolved Hide resolved
- Cell magics are now only processed if they are known Python cell magics. Earlier, all
cell magics were tokenized, leading to possible indentation errors e.g. with
`%%writefile`. (#2630)
Expand Down
1 change: 0 additions & 1 deletion Pipfile
Expand Up @@ -42,7 +42,6 @@ platformdirs= ">=2"
click = ">=8.0.0"
mypy_extensions = ">=0.4.3"
pathspec = ">=0.8.1"
regex = ">=2021.4.4"
tomli = ">=0.2.6, <2.0.0"
typed-ast = "==1.4.3"
typing_extensions = {markers = "python_version < '3.10'", version = ">=3.10.0.0"}
Expand Down
875 changes: 270 additions & 605 deletions Pipfile.lock

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions docs/integrations/editors.md
Expand Up @@ -204,7 +204,7 @@ Traceback (most recent call last):
ImportError: /home/gui/.vim/black/lib/python3.7/site-packages/typed_ast/_ast3.cpython-37m-x86_64-linux-gnu.so: undefined symbool: PyExc_KeyboardInterrupt
```

Then you need to install `typed_ast` and `regex` directly from the source code. The
Then you need to install `typed_ast` directly from the source code. The
error happens because `pip` will download [Python wheels](https://pythonwheels.com/) if
they are available. Python wheels are a new standard of distributing Python packages and
packages that have Cython and extensions written in C are already compiled, so the
Expand All @@ -213,21 +213,20 @@ environment inside Vim does not match with those already compiled C extensions a
kind of errors are the result. Luckily there is an easy fix: installing the packages
from the source code.

The two packages that cause the problem are:
The package that causes problems is:

- [regex](https://pypi.org/project/regex/)
- [typed-ast](https://pypi.org/project/typed-ast/)

Now remove those two packages:

```console
$ pip uninstall regex typed-ast -y
$ pip uninstall typed-ast -y
```

And now you can install them with:

```console
$ pip install --no-binary :all: regex typed-ast
$ pip install --no-binary :all: typed-ast
```

The C extensions will be compiled and now Vim's Python environment will match. Note that
Expand All @@ -237,7 +236,7 @@ Ubuntu/Debian do `sudo apt-get install build-essential python3-dev`).
If you later want to update _Black_, you should do it like this:

```console
$ pip install -U black --no-binary regex,typed-ast
$ pip install -U black --no-binary typed-ast
```

### With ALE
Expand Down
1 change: 0 additions & 1 deletion setup.py
Expand Up @@ -101,7 +101,6 @@ def find_python_files(base: Path) -> List[Path]:
"platformdirs>=2",
"tomli>=0.2.6,<2.0.0",
"typed-ast>=1.4.2; python_version < '3.8' and implementation_name == 'cpython'",
"regex>=2021.4.4",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So nice.

"pathspec>=0.9.0, <1",
"dataclasses>=0.6; python_version < '3.7'",
"typing_extensions>=3.10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/black/trans.py
Expand Up @@ -4,7 +4,7 @@
from abc import ABC, abstractmethod
from collections import defaultdict
from dataclasses import dataclass
import regex as re # We need recursive patterns here (?R)
import re
from typing import (
Any,
Callable,
Expand Down