Skip to content

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

Merged
merged 4 commits into from
Apr 23, 2021

Conversation

E-Paine
Copy link
Contributor

@E-Paine E-Paine commented Apr 20, 2021

Minor reformatting, some of which was taken from #22682

Copy link
Member

@terryjreedy terryjreedy left a 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.

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 \
Copy link
Member

Choose a reason for hiding this comment

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

Backslash not needed.

@@ -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 + \
Copy link
Member

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.

"hit": idleConf.GetHighlight(theme, "hit"),
}
}
Copy link
Member

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.

@@ -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))
Copy link
Member

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'.

@@ -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"
)
)
Copy link
Member

Choose a reason for hiding this comment

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

See above.

@python python deleted a comment from bedevere-bot Apr 23, 2021
@terryjreedy terryjreedy merged commit 702a088 into python:master Apr 23, 2021
@miss-islington
Copy link
Contributor

Thanks @E-Paine for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 23, 2021
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>
@bedevere-bot
Copy link

GH-25547 is a backport of this pull request to the 3.9 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Apr 23, 2021
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 23, 2021
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>
@bedevere-bot
Copy link

GH-25548 is a backport of this pull request to the 3.8 branch.

miss-islington added a commit that referenced this pull request Apr 23, 2021
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>
terryjreedy pushed a commit that referenced this pull request Apr 23, 2021
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip issue skip news type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants