-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix repr highlighter #1920
Fix repr highlighter #1920
Conversation
enum.Flag allows more than one bit to be set, and its repr will show something like <Permission.READ|WRITE: 3>. For this to display correctly, we need to add the pipe symbol to the tag regex.
Special characters lose their special meaning in character sets, so there's no need to escape them with a backslash. Furthermore, some backslash escaped characters have no special meaning, so the backslash can be removed as well. "]" does normally close a set, except when it's the first character. Similarly, "-" has no special meaning at the beginning or the end. Therefore, the order in a few character sets had to be slightly modified. Just to be sure, the old and new versions of the regexp were confirmed to be equivalent via re.compile with the re.DEBUG flag and comparing the output.
Codecov Report
@@ Coverage Diff @@
## master #1920 +/- ##
==========================================
- Coverage 99.82% 99.81% -0.02%
==========================================
Files 71 71
Lines 6943 7033 +90
==========================================
+ Hits 6931 7020 +89
- Misses 12 13 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
THanks |
Type of changes
Checklist
Description
This PR contains 2 changes:
enum.Flag supports more than one bit to be set, and it is displayed like
<Permission.READ|WRITE: 3>
. The|
character was not recognised by ReprHighlighter as part of a tag_name, causing only the first part to be highlighted.This is purely cosmetic, but I found the regexes to be really difficult to parse because of all the backslashes. Most of those actually weren't necessary, the commit explains the details further. However, this commit is completely optional.