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

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:

Reduce usage of regex (#2644)
authorJelle Zijlstra <jelle.zijlstra@gmail.com>
Wed, 1 Dec 2021 02:01:36 +0000 (18:01 -0800)
committerGitHub <noreply@github.com>
Wed, 1 Dec 2021 02:01:36 +0000 (18:01 -0800)
commit5e2bb528e09df368ed7dea6b7fb9c53e799a569f
tree019a110db75f99c1e1e46736cc64e0f497b2d19a
parentb336b390d0613348e6208b392e41e5512b0a85be
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.
CHANGES.md
src/black/__init__.py
src/black/comments.py
src/black/strings.py
src/black/trans.py
src/blib2to3/pgen2/conv.py
src/blib2to3/pgen2/tokenize.py