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
Reduce usage of regex #2644
Reduce usage of regex #2644
Changes from 9 commits
c097111
1bcaff6
d0c7213
e7a8d67
8b14fc5
275e811
444415e
2979e2c
4ab530c
e809b80
6dfc313
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ | |
""" | ||
|
||
# Python imports | ||
import regex as re | ||
import re | ||
|
||
# Local imports | ||
from pgen2 import grammar, token | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ | |
__author__ = "Ka-Ping Yee <ping@lfw.org>" | ||
__credits__ = "GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, Skip Montanaro" | ||
|
||
import regex as re | ||
import re | ||
from codecs import BOM_UTF8, lookup | ||
from blib2to3.pgen2.token import * | ||
|
||
|
@@ -86,7 +86,7 @@ def _combinations(*l): | |
Comment = r"#[^\r\n]*" | ||
Ignore = Whitespace + any(r"\\\r?\n" + Whitespace) + maybe(Comment) | ||
Name = ( # this is invalid but it's fine because Name comes after Number in all groups | ||
r"\w+" | ||
r"[^\s#\(\)\[\]\{\}+\-*/!@$%^&=|;:'\",\.<>/?`~\\]+" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At this point we might need to add a FAQ entry describing why Black is incredibly inconsistent detecting invalid syntax. We don't promise that Black will fail on all invalid code but people do reasonably assume consistency. We don't need to get into the nitty gritty but simply explaining how it requires less work while achieving a high degree compatibility. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I can add that separately. |
||
) | ||
|
||
Binnumber = r"0[bB]_?[01]+(?:_[01]+)*" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ | |
|
||
import click | ||
import pytest | ||
import regex as re | ||
import re | ||
from click import unstyle | ||
from click.testing import CliRunner | ||
from pathspec import PathSpec | ||
|
@@ -70,7 +70,7 @@ | |
R = TypeVar("R") | ||
|
||
# Match the time output in a diff, but nothing else | ||
DIFF_TIME = re.compile(r"\t[\d-:+\. ]+") | ||
DIFF_TIME = re.compile(r"\t[\d\-:+\. ]+") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch! |
||
|
||
|
||
@contextmanager | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this worth mentioning in the changelog? This doesn't really have an impact on end users since we still depend on regex unconditionally so all of the problem involved in that will persist. Not a big deal but I wanted to flag this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thinking was that there's some chance it does have an impact on end users, so it's worth mentioning.