-
Notifications
You must be signed in to change notification settings - Fork 38
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: KeyError in CodeSyntaxHighlight #258
Conversation
For me, it looks like a bug in pigments. |
what do you suggest then? |
I will check this in the following days. I am sorry that I forgot about this issue. |
So yes, it is error reported in pygments pygments/pygments#2149 Looking into rich code https://github.com/Textualize/rich/blob/43d3b04725ab9731727fb1126e35980c62f32377/rich/syntax.py#L152 This PR may be a good approach. Hovewer I prefer to add self._style = {name: get_text_char_format(style) for name, style in self.style} I feel like using I cannot restart CI. Maybe too long time since last commit? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #258 +/- ##
==========================================
- Coverage 87.13% 86.98% -0.15%
==========================================
Files 46 46
Lines 3443 3443
==========================================
- Hits 3000 2995 -5
- Misses 443 448 +5 ☔ View full report in Codecov by Sentry. |
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.
superqt still supports python 3.8 so need to use types from typing
, not builtins
happy to drop it now that it's EOL. will open new issue |
thanks @Czaki. is this something you want to see done in this PR before merge? |
Co-authored-by: Grzegorz Bokota <[email protected]>
I noticed that
CodeSyntaxHighlight
sometimes fails to highlight the texts. This PR fixes the KeyError just by replacing the__getitem__
withget
. I encountered this bug when I tried to highlight my pre-commit-config.yaml file, so I cannot tell when this happens.Output: