-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
Reformat idlelib colorizer #25479
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
Reformat idlelib colorizer #25479
Conversation
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.
Thank you. I am making changes and will look at rest of module. After I merge, I will see if this merges cleanlyly into original PR. I believe it will.
Lib/idlelib/colorizer.py
Outdated
def make_pat(): | ||
kw = r"\b" + any("KEYWORD", keyword.kwlist) + r"\b" | ||
builtinlist = [str(name) for name in dir(builtins) | ||
if not name.startswith('_') and \ | ||
name not in keyword.kwlist] | ||
if not name.startswith('_') and \ |
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.
Backslash not needed.
Lib/idlelib/colorizer.py
Outdated
@@ -25,12 +27,14 @@ def make_pat(): | |||
sq3string = stringprefix + r"'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?" | |||
dq3string = stringprefix + r'"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?' | |||
string = any("STRING", [sq3string, dq3string, sqstring, dqstring]) | |||
return kw + "|" + builtin + "|" + comment + "|" + string +\ | |||
return kw + "|" + builtin + "|" + comment + "|" + string + \ |
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.
Backslash can be avoided with ()s.
Lib/idlelib/colorizer.py
Outdated
"hit": idleConf.GetHighlight(theme, "hit"), | ||
} | ||
} |
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.
Original was equally acceptible in PEP 8. I will revert.
Lib/idlelib/colorizer.py
Outdated
@@ -215,7 +222,7 @@ def recolorize(self): | |||
t0 = time.perf_counter() | |||
self.recolorize_main() | |||
t1 = time.perf_counter() | |||
if DEBUG: print("%.3f seconds" % (t1-t0)) | |||
if DEBUG: print("%.3f seconds" % (t1 - t0)) |
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.
Spaces are not required or even wrong. "c = (a + b) * (a - b)" is labelled 'wrong'.
Lib/idlelib/colorizer.py
Outdated
@@ -316,7 +323,7 @@ def _color_delegator(parent): # htest # | |||
"b'x',B'x', br'x',Br'x',bR'x',BR'x', rb'x', rB'x',Rb'x',RB'x'\n" | |||
"# Invalid combinations of legal characters should be half colored.\n" | |||
"ur'x', ru'x', uf'x', fu'x', UR'x', ufr'x', rfu'x', xf'x', fx'x'\n" | |||
) | |||
) |
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.
See above.
Thanks @E-Paine for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9. |
Also replace if-then and and-or with conditional expressions. Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> (cherry picked from commit 702a088) Co-authored-by: E-Paine <63801254+E-Paine@users.noreply.github.com>
GH-25547 is a backport of this pull request to the 3.9 branch. |
Also replace if-then and and-or with conditional expressions. Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> (cherry picked from commit 702a088) Co-authored-by: E-Paine <63801254+E-Paine@users.noreply.github.com>
GH-25548 is a backport of this pull request to the 3.8 branch. |
Also replace if-then and and-or with conditional expressions. Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> (cherry picked from commit 702a088) Co-authored-by: E-Paine <63801254+E-Paine@users.noreply.github.com>
Also replace if-then and and-or with conditional expressions. Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> (cherry picked from commit 702a088) Co-authored-by: E-Paine <63801254+E-Paine@users.noreply.github.com> Co-authored-by: E-Paine <63801254+E-Paine@users.noreply.github.com>
Minor reformatting, some of which was taken from #22682