Unverified Commit 544ea9c2 authored by Bryan Bugyi's avatar Bryan Bugyi Committed by GitHub
Browse files

Improve String Handling (#1132)

This pull request's main intention is to wraps long strings (as requested by #182); however, it also provides better string handling in general and, in doing so, closes the following issues:

Closes #26
Closes #182
Closes #933
Closes #1183
Closes #1243
parent 07c046b7
Loading
Loading
Loading
Loading
+2274 −272

File changed.

Preview size limit exceeded, changes collapsed.

+2 −2
Changes for blib2to3/pgen2/pgen.py: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -167,8 +167,8 @@ def calcfirst(self, name: Text) -> None:
            for symbol in itsfirst:
                if symbol in inverse:
                    raise ValueError(
                        "rule %s is ambiguous; %s is in the"
                        " first sets of %s as well as %s"
                        "rule %s is ambiguous; %s is in the first sets of %s as well"
                        " as %s"
                        % (name, symbol, label, inverse[symbol])
                    )
                inverse[symbol] = label
+3 −1
Changes for blib2to3/pgen2/tokenize.py: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -78,7 +78,9 @@ def _combinations(*l):
Whitespace = r"[ \f\t]*"
Comment = r"#[^\r\n]*"
Ignore = Whitespace + any(r"\\\r?\n" + Whitespace) + maybe(Comment)
Name = r"\w+"  # this is invalid but it's fine because Name comes after Number in all groups
Name = (  # this is invalid but it's fine because Name comes after Number in all groups
    r"\w+"
)

Binnumber = r"0[bB]_?[01]+(?:_[01]+)*"
Hexnumber = r"0[xX]_?[\da-fA-F]+(?:_[\da-fA-F]+)*[lL]?"
+1 −2
Changes for gallery/gallery.py: 1 added line, 2 removed lines.
Original line number Diff line number Diff line
@@ -268,8 +268,7 @@ def main() -> None:
        "-v",
        "--version",
        help=(
            "Version for given PyPI package. "
            "Will be discarded if used with -t option."
            "Version for given PyPI package. Will be discarded if used with -t option."
        ),
    )
    parser.add_argument(
+4 −2
Changes for tests/data/cantfit.py: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -75,8 +75,10 @@
)
# long arguments
normal_name = normal_function_name(
    "but with super long string arguments that on their own exceed the line limit so there's no way it can ever fit",
    "eggs with spam and eggs and spam with eggs with spam and eggs and spam with eggs with spam and eggs and spam with eggs",
    "but with super long string arguments that on their own exceed the line limit so"
    " there's no way it can ever fit",
    "eggs with spam and eggs and spam with eggs with spam and eggs and spam with eggs"
    " with spam and eggs and spam with eggs",
    this_is_a_ridiculously_long_name_and_nobody_in_their_right_mind_would_use_one_like_it=0,
)
string_variable_name = "a string that is waaaaaaaayyyyyyyy too long, even in parens, there's nothing you can do"  # noqa
Loading